.theme-picker { position: relative; flex-shrink: 0; }
.theme-picker > summary { display: grid; place-items: center; list-style: none; cursor: pointer; }
.theme-picker > summary::-webkit-details-marker { display: none; }
.theme-picker > summary svg { width: 18px; height: 18px; }
.theme-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 100; width: 160px; padding: 5px; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 6px; box-shadow: 0 8px 24px #0002; }
.theme-menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 9px 12px; text-align: left; border: 0; background: transparent; color: var(--ink); border-radius: 4px; font-size: 13px; }
.theme-menu svg { width: 17px; height: 17px; }
.theme-menu button:hover { background: var(--soft); }
.theme-menu button[aria-pressed="true"] { color: var(--green); background: var(--green-soft); }
.theme-picker summary:focus-visible, .theme-menu button:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
@media screen {
  html[data-theme="dark"] { color-scheme: dark; background: #151718; }
  html[data-theme="dark"] .operations-system,
  html[data-theme="dark"] .operations-system .modal.product-editor-modal {
    --ink: #e6e9eb; --ink-2: #d6dcdf; --muted: #a1aaaf;
    --canvas: #151718; --paper: #202325; --soft: #282c2f;
    --line: #383e42; --line-strong: #565f65;
    --green: #8cd4b6; --green-soft: #253e35;
    --blue: #a1c5f6; --blue-soft: #293849;
    --amber: #e3c17c; --amber-soft: #413925;
    --red: #f1a1a7; --red-soft: #452e33;
    background: var(--canvas); color: var(--ink);
  }
  html[data-theme="dark"] .operations-system .modal.product-editor-modal { background: var(--paper); }
  html[data-theme="dark"] .operations-system :is(.sidebar,.sidebar-foot,.topbar,.panel,.data-panel,.modal,.modal-head,.modal-body,.ops-task,.ops-table-wrap,.ops-stages,.order-list-button,.order-desk,.desk-tabs,.order-workspace-head,.order-activity,.detail-section,.line-item,.admin-mobile-tabs,.login-card,.country-card,.proxy-country-card,.commerce-policy-card,.ai-provider-card,.ai-feature-card,.product-editor,.product-editor-toolbar,.product-editor-main,.product-editor-sidebar,.product-editor-section,.product-variant-card,.variant-card,.media-card,.editor-card,.editor-panel) {
    background: var(--paper); color: var(--ink); border-color: var(--line); box-shadow: none;
  }
  html[data-theme="dark"] .operations-system :is(.desk-side,.desk-attention,.modal-foot,.proxy-country-card > header,.nav-search,.order-filter-button b,.order-desk .desk-state,.order-desk .desk-settlement > summary,.order-desk .desk-history > summary) { background: var(--soft); color: var(--muted); }
  html[data-theme="dark"] .operations-system .nav-group.is-expanded > .nav-parent { background: var(--soft); color: var(--muted); }
  html[data-theme="dark"] .operations-system :is(.nav-link,.nav-parent,.icon-button,.mobile-order-back,.button.ghost,.desk-tabs button,.desk-contact article p,.desk-facts dt,.desk-technical h5,.desk-records > summary,.desk-technical > summary,.desk-procurement small) { color: var(--muted); }
  html[data-theme="dark"] .operations-system :is(.sidebar-brand strong,.admin-identity strong,.table-primary,.order-list-main strong,.order-list-side strong) { color: var(--ink); }
  html[data-theme="dark"] .operations-system .nav-link.active { background: var(--green-soft); color: var(--green); }
  html[data-theme="dark"] .operations-system :is(.nav-link:hover,.nav-parent:hover,.ops-task:hover,.order-list-button:hover,.ops-stock-list > button:hover,tbody tr:hover) { background: var(--soft); }
  html[data-theme="dark"] .operations-system :is(input,select,textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]) { background: var(--canvas); color: var(--ink); border-color: var(--line-strong); }
  html[data-theme="dark"] .operations-system :is(input,textarea)::placeholder { color: #89949b; opacity: 1; }
  html[data-theme="dark"] .operations-system :is(input,select,textarea):focus { outline-color: #589d84; border-color: var(--green); }
  html[data-theme="dark"] .operations-system :is(input,select,textarea,button):disabled { opacity: .6; }
  html[data-theme="dark"] .operations-system :is(.button.secondary,.icon-button,.order-filter-button.active,.product-type-tab,.segmented button,.tabs button) { background: var(--paper); color: var(--ink); border-color: var(--line-strong); }
  html[data-theme="dark"] .operations-system .button.primary { background: #25765d; border-color: #449477; color: #fff; }
  html[data-theme="dark"] .operations-system .button.primary:hover { background: #2e886c; }
  html[data-theme="dark"] .operations-system .button.danger { background: var(--red-soft); color: var(--red); border-color: #84505a; }
  html[data-theme="dark"] .operations-system :is(a,.text-button,.desk-tabs button[aria-selected="true"]) { color: var(--green); }
  html[data-theme="dark"] .operations-system :is(thead,th) { background: var(--soft); color: var(--muted); }
  html[data-theme="dark"] .operations-system :is(td,.panel-head,.panel-body,.desk-section,.desk-side,.desk-tabs,.desk-payment-state,.desk-shipping-state,.desk-total,.line-item,.order-workspace-head,.operation-facts > div) { border-color: var(--line); }
  html[data-theme="dark"] .operations-system :is(.badge.gray,.badge.grey) { background: var(--soft); color: var(--muted); }
  html[data-theme="dark"] .operations-system :is(.badge.green,.desk-state.is-good) { background: var(--green-soft); color: var(--green); }
  html[data-theme="dark"] .operations-system .badge.blue { background: var(--blue-soft); color: var(--blue); }
  html[data-theme="dark"] .operations-system :is(.badge.amber,.desk-state.is-pending,.desk-attention:has(button)) { background: var(--amber-soft); color: var(--amber); }
  html[data-theme="dark"] .operations-system .badge.red { background: var(--red-soft); color: var(--red); }
  html[data-theme="dark"] .operations-system .desk-settlement-status { color: var(--amber); }
  html[data-theme="dark"] .operations-system :is(.order-desk .desk-section > h4,.order-desk .detail-section-heading) { color: var(--ink); background: transparent; border-color: var(--line); }
  html[data-theme="dark"] .operations-system :is(.ops-stages meter,.ops-stages meter::-webkit-meter-bar) { background: var(--soft); }
  html[data-theme="dark"] .operations-system .modal-backdrop { background: #0009; }
  html[data-theme="dark"] .operations-system :is(.brand-glyph,#user-avatar) { background: var(--soft); color: var(--ink); }
  html[data-theme="dark"] .operations-system .admin-timeline li::before { background: var(--paper); border-color: var(--line-strong); }
  html[data-theme="dark"] .operations-system :is(.loading-skeleton,.skeleton) { background: var(--soft); }
  html[data-theme="dark"] .operations-system .product-type-tab.active { background: var(--green-soft); color: var(--green); }
  html[data-theme="dark"] .operations-system :is(.ai-model-price dd,.ai-ops-metrics strong) { color: var(--ink); }
  html[data-theme="dark"] .operations-system :is(.muted,.ai-price-heading,.ai-model-price dt,.ai-control small,.ai-control .panel-head > .muted,.ai-ops-metrics article > span,.ai-ops-metrics article > small,.ai-connection-status) { color: var(--muted); }
  html[data-theme="dark"] .operations-system .ai-connection-status.connected { color: var(--green); }
  html[data-theme="dark"] .operations-system :is(.ai-model-price,.ai-connection-grid form) { border-color: var(--line); }
  html[data-theme="dark"] .operations-system .data-table tr { background: var(--paper); }
  html[data-theme="dark"] .operations-system :is(.health-card,.queue-row,.product-editor-body,.product-editor-meta,.product-editor-copy,.editor-section,.check-field,.rich-toolbar,.gmail-toolbar,.gmail-toolbar .toolbar-more-panel,.gallery-panel,.content-image-uploader,.variant-bulk-editor,.product-editor-gallery,.product-entity-fields,.variant-entity-fields,.product-mobile-nav,.product-desktop-nav,.ai-generation-card,.ai-ops-metrics article,.marketplace-invoice-header,.marketplace-invoice-file,.marketplace-invoice-batch,.commerce-fee-field > div,.product-basic-section,.product-seo-section,.main-product-image-section) { background: var(--paper); color: var(--ink); border-color: var(--line); }
  html[data-theme="dark"] .operations-system :is(.row-actions button,.row-actions > a,.rich-toolbar button,.rich-toolbar label,.gmail-toolbar button,.product-desktop-nav button,.product-mobile-nav button,.editor-tabs button) { color: var(--muted); background: transparent; border-color: var(--line); }
  html[data-theme="dark"] .operations-system :is(.row-actions button:hover,.rich-toolbar button:hover,.gmail-toolbar button:hover,.editor-tabs button.active,.product-desktop-nav button[aria-pressed="true"]) { color: var(--green); background: var(--green-soft); }
  html[data-theme="dark"] .operations-system :is(.ai-product-import,.marketplace-invoice-isolation) { background: var(--green-soft); color: var(--ink); border-color: #527d6d; }
  html[data-theme="dark"] .operations-system :is(.product-type-banner.proxy,.marketplace-invoice-issues,.member-form-message.pending,.taxonomy-diagnostics.is-warning) { background: var(--amber-soft); color: var(--amber); border-color: #786039; }
  html[data-theme="dark"] .operations-system :is(.ai-product-import[data-state="error"],.marketplace-invoice-issues.error,.member-form-message.error,.operation-warning-critical) { background: var(--red-soft); color: var(--red); border-color: #84505a; }
  html[data-theme="dark"] .operations-system .order-desk .desk-state.is-pending { background: var(--amber-soft); color: var(--amber); }
  html[data-theme="dark"] .operations-system .order-desk .desk-state.is-good { background: var(--green-soft); color: var(--green); }
  html[data-theme="dark"] .operations-system #nav-search { background: transparent; }
  html[data-theme="dark"] .operations-system .main-image-tile.is-empty { background: var(--soft); color: var(--muted); }
  html[data-theme="dark"] .operations-system .ops-stages meter::-webkit-meter-bar { background: var(--soft); }
  html[data-theme="dark"] .operations-system .ops-stages meter::-moz-meter-bar { background: #7eaaa0; }
  html[data-theme="dark"] .operations-system .page-actions.has-mobile-action-menu.is-open > :not(.mobile-page-actions-toggle) { background: var(--paper); border-color: var(--line); }
  /* Product copy and document previews retain their published colors. */
  html[data-theme="dark"] .operations-system :is(.rich-editor,.copy-preview,.storefront-preview-shell,.document-viewer-frame) { --muted: #66717b; color-scheme: light; background: #fff; color: #20252b; }
}
@media (max-width: 760px) {
  .operations-system .theme-picker > summary { width: 44px; height: 44px; }
  .theme-menu button { min-height: 44px; }
}
@media print { .theme-picker { display: none; } }
