/* Aparência da ferramenta. Nenhum filtro é aplicado às artes ou às imagens. */
.interface-theme-toggle {
  width:36px; height:36px; flex:0 0 36px; display:inline-grid; place-items:center;
  padding:0; border:1px solid #d4dde9; border-radius:9px;
  color:#536275; background:#fff; cursor:pointer;
}
.interface-theme-toggle:hover { background:#eef3f9; border-color:#9aabbe; }
.interface-theme-toggle:focus-visible { outline:3px solid #d71920; outline-offset:3px; }
.interface-theme-toggle .theme-icon-sun { display:none; }
html[data-ui-theme="dark"] .interface-theme-toggle .theme-icon-sun { display:block; }
html[data-ui-theme="dark"] .interface-theme-toggle .theme-icon-moon { display:none; }

html[data-ui-theme="dark"] {
  color-scheme:dark;
  --appearance-bg:#11151d;
  --appearance-panel:#191f2b;
  --appearance-raised:#232c3b;
  --appearance-field:#131a25;
  --appearance-line:#354155;
  --appearance-ink:#eef2f7;
  --appearance-muted:#abb8ca;
  --appearance-highlight:#ff9a9f;
  /* Os cartazes A4 já usam tokens exclusivos da interface. */
  --ui-bg:#11151d; --ui-surface:#191f2b; --ui-border:#354155;
  --ui-text:#eef2f7; --ui-muted:#abb8ca;
}
html[data-ui-theme="dark"] body.studio-retail { background:var(--appearance-bg); }

/* Tokens locais: não chegam à prancheta do encarte. */
html[data-ui-theme="dark"] body.studio-retail :is(
  .topbar,.sidebar,.preview-toolbar,.editor-panel,.model-picker-section,.page-controls,
  .mobile-panel,.mobile-bottombar,.product-sidebar,.image-picker-dialog,.product-import-dialog,
  .billing-dialog,.lab-export-dialog,.tile-editor-sheet,.ms-tour-card,.auth-card,.user-menu-pop,.help-bubble
) {
  --ink:var(--appearance-ink); --muted:var(--appearance-muted);
  --surface:var(--appearance-panel); --surface-strong:var(--appearance-raised); --line:var(--appearance-line);
  --studio-ink:var(--appearance-ink); --studio-muted:var(--appearance-muted); --studio-line:var(--appearance-line);
  --brand-blue-soft:#24394e; --brand-orange-soft:#412d24; --studio-red-soft:#3b242c;
  color:var(--appearance-ink); border-color:var(--appearance-line);
}
html[data-ui-theme="dark"] body.studio-retail :is(
  .topbar,.sidebar,.editor-panel,.product-sidebar,.product-sidebar-head,.mobile-card,
  .mobile-bottombar,.image-picker-dialog,.image-picker-head,.image-picker-pagination,
  .poster-bg-actions,.product-import-dialog,.billing-dialog,.lab-export-dialog,.tile-editor-sheet,
  .tile-editor-head,.tile-editor-actions,.ms-tour-card,.auth-card,.user-menu-pop,.help-bubble
) { background:var(--appearance-panel); color:var(--appearance-ink); border-color:var(--appearance-line); }
html[data-ui-theme="dark"] body.studio-retail :is(.preview-stage,.mobile-panel,.poster-wrap) { background:var(--appearance-bg); }
html[data-ui-theme="dark"] body.studio-retail :is(
  .product-search-card,.search-results-card,.premium-zone,.destaque-showcase,.lab-quick-campaigns,.lab-topic-library,
  .image-search-refine,.poster-bg-grid,.tile-bg-grid,.price-tag-grid,.image-picker-grid,
  .company-info-section,.encarte-card,.import-table-wrap,.billing-plan,.billing-state,.auth-check-email-tips,.auth-tabs,.tile-editor-preview
) { background:var(--appearance-field); border-color:var(--appearance-line); color:var(--appearance-ink); }
html[data-ui-theme="dark"] body.studio-retail :is(.preview-toolbar,.model-picker-section,.page-controls) {
  background:transparent; color:var(--appearance-ink); border-color:var(--appearance-line);
}

/* Campos e controles são explicitamente limitados aos painéis da ferramenta. */
html[data-ui-theme="dark"] body.studio-retail :is(
  .topbar,.sidebar,.preview-toolbar,.editor-panel,.mobile-panel,.product-sidebar,
  .image-picker-dialog,.product-import-dialog,.billing-dialog,.tile-editor-sheet,.auth-card
) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),textarea,select) {
  color:var(--appearance-ink); background:var(--appearance-field); border-color:var(--appearance-line);
}
html[data-ui-theme="dark"] body.studio-retail :is(input,textarea)::placeholder { color:#91a0b5; opacity:1; }
html[data-ui-theme="dark"] body.studio-retail :is(
  .secondary-button,.ghost-button,.text-tool-button,.toolbar-art-btn,.zoom-btn,.zoom-select,
  .modal-close-button,.file-button-inline,.mobile-destaque-button,.mobile-size-card,.model-card,
  .ms-tour-back,.help-fab,.help-replay-tour,.billing-secondary,.billing-close,.auth-google,
  .image-search-suggestion,.encarte-card-button,.stepper button,.interface-theme-toggle,#labExampleButton,
  .tile-editor-action-btn,.tile-editor-close,.sidebar-copy-chip,.sidebar-reorder-btn
) { background:var(--appearance-raised); color:var(--appearance-ink); border-color:var(--appearance-line); }
html[data-ui-theme="dark"] body.studio-retail :is(
  .secondary-button,.ghost-button,.text-tool-button,.toolbar-art-btn,.modal-close-button,
  .file-button-inline,.ms-tour-back,.help-fab,.interface-theme-toggle,.auth-google
):hover { background:#2c384c; color:#fff; border-color:#63738c; }
html[data-ui-theme="dark"] body.studio-retail :is(
  .app-tab.active,.model-card.active,.mobile-size-card.active,.encarte-card.current,
  .lab-campaign[aria-pressed="true"],.lab-quick-campaign.active,.image-choice.active
) { background:#3b242c; color:var(--appearance-highlight); border-color:#ed6672; }
html[data-ui-theme="dark"] body.studio-retail .app-tab:hover { background:var(--appearance-raised); color:var(--appearance-ink); }
html[data-ui-theme="dark"] body.studio-retail .lab-new-campaigns-link { color:var(--appearance-highlight); }

/* Legendas e hierarquia de texto, sem alterar os textos das artes. */
html[data-ui-theme="dark"] body.studio-retail :is(
  .paste-label,.lab-library-heading h2,.lab-library-heading h3,.lab-quick-campaigns h3,
  .lab-campaign>strong,.image-picker-head h2,.model-name,.model-title,.mobile-card h3,
  .company-info-section>summary,.ms-tour-card h3,.help-faq summary,.voucher-section h3,
  .auth-card h1,.user-menu-name,.encarte-card-title,.tile-editor-head h3
) { color:var(--appearance-ink); }
html[data-ui-theme="dark"] body.studio-retail :is(
  .paste-example,.lab-library-heading p,.lab-quick-campaigns p,.lab-campaign>span,
  .image-picker-head p,.panel-head p,.campaign-controls span,.sidebar-field>span,
  .company-info-hint,.company-info-section>summary small,.model-picker-head p,.model-dimensions,
  .picker-section-title,.image-picker-status,.image-search-refine label,.ms-tour-card p,
  .ms-tour-eyebrow,.ms-tour-skip,.help-faq p,.import-hint,.billing-benefits,.billing-message,
  .billing-plan>p:last-child,.voucher-section p,.voucher-section label,.encarte-card-meta,
  .user-menu-email,.auth-fineprint,.auth-card-head p,.auth-divider,.auth-field span,.auth-tab,
  .auth-check-email-body,.auth-check-email-instructions,.studio-preview-heading,.lab-export-dialog p,
  .compact-field,.toggle-field,.lab-topic-library p,.lab-topic-library label,.model-picker-head h2,.studio-footer-settings p
) { color:var(--appearance-muted); }
html[data-ui-theme="dark"] body.studio-retail :is(.lab-campaign,.lab-quick-campaign,.image-choice,.price-tag-choice,.poster-bg-choice) {
  background:var(--appearance-panel); color:var(--appearance-ink); border-color:var(--appearance-line);
}
/* Miniaturas têm um fundo neutro para visualizar corretamente PNGs transparentes. */
html[data-ui-theme="dark"] body.studio-retail .poster-bg-choice .poster-bg-name {
  background:var(--appearance-raised); color:var(--appearance-ink); border-color:var(--appearance-line);
}
html[data-ui-theme="dark"] body.studio-retail :is(.help-dot,.help-replay-tour) { background:#2d3b50; color:#d6e5fa; }
html[data-ui-theme="dark"] body.studio-retail :is(.help-faq,.billing-head,.voucher-section,.import-table th,.import-table td,.auth-tabs,.auth-divider::before) { border-color:var(--appearance-line); }
html[data-ui-theme="dark"] body.studio-retail .import-table th { background:var(--appearance-raised); color:var(--appearance-ink); }
html[data-ui-theme="dark"] body.studio-retail .import-row-error { background:#412b23; }
html[data-ui-theme="dark"] body.studio-retail :is(.billing-test,.export-check-list li) { background:#342e20; color:#f3d68c; border-color:#766035; }
html[data-ui-theme="dark"] body.studio-retail :is(.billing-access,.billing-eyebrow) { color:#95deb3; }
html[data-ui-theme="dark"] body.studio-retail :is(.danger-button,.clear-all-button,.user-menu-logout) { color:#ffa4ab; border-color:#704047; background:#34232b; }
html[data-ui-theme="dark"] body.studio-retail .top-actions .save-status { color:#a4ddb7; background:#22382c; }
html[data-ui-theme="dark"] body.studio-retail .top-actions .save-status.pending { color:#f2d58e; background:#3c3320; }
html[data-ui-theme="dark"] body.studio-retail .top-actions .save-status.error { color:#ffabb1; background:#40252b; }
/* O wordmark original continua intacto, sobre suporte claro para legibilidade. */
html[data-ui-theme="dark"] body.studio-retail .app-tab-wordmark { background:#fff; border-radius:5px; }
html[data-ui-theme="dark"] body.studio-retail .auth-tab.active { background:var(--appearance-raised); color:var(--appearance-highlight); }
html[data-ui-theme="dark"] body.studio-retail :is(.auth-link,.auth-check-email h2,.auth-check-email-body strong) { color:#9bc5ff; }
html[data-ui-theme="dark"] body.studio-retail :is(button,input,select,textarea,a,[tabindex]):focus-visible { outline-color:#ff9a9f !important; }

/* Cartaz A4: controles do iframe acompanham a preferência, papel/arte preservados. */
html[data-ui-theme="dark"] #app-header { background:var(--appearance-panel) !important; border-color:var(--appearance-line) !important; }
html[data-ui-theme="dark"] #app-header :is(h1,p),
html[data-ui-theme="dark"] :is(.control-label,.section-title) { color:var(--appearance-muted) !important; }
html[data-ui-theme="dark"] :is(.layout-option,.tab-btn.active,.btn-secondary,.gallery-selected-card) { background:var(--appearance-raised) !important; color:var(--appearance-ink) !important; border-color:var(--appearance-line) !important; }
html[data-ui-theme="dark"] :is(.layout-option.active,.open-gallery-btn) { background:#412d24 !important; color:#ffd0ae !important; }
html[data-ui-theme="dark"] .layout-option.active .layout-name { color:#ffd0ae !important; }
html[data-ui-theme="dark"] .control-card input[type="file"] { background:var(--appearance-field) !important; color:var(--appearance-muted) !important; border-color:var(--appearance-line) !important; }
html[data-ui-theme="dark"] :is(.gallery-modal-dialog,.gallery-modal-head) { background:var(--appearance-panel) !important; color:var(--appearance-ink) !important; }
html[data-ui-theme="dark"] .gallery-modal-head h2 { color:var(--appearance-ink) !important; }
html[data-ui-theme="dark"] :is(.poster,.poster-paper) { color-scheme:light; }
/* Texto herdado do papel A4 mantém a cor da interface clara original. */
html[data-ui-theme="dark"] .poster-paper { color:#1d2a3a; }

@media (max-width:768px) {
  .interface-theme-toggle { width:34px; height:34px; flex-basis:34px; }
}
@media print {
  .interface-theme-toggle { display:none; }
}
