/* Explicit selection overrides the older device-only dark palettes. */
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101820; --paper: #101820; --card: #1b2630;
  --text: #e9eff4; --ink: #e9eff4; --muted: #acbbc6; --line: #364550;
  --primary: #96baff; --primary-soft: #243651; --blue: #96baff; --blue-soft: #243651;
  --green: #a3dbb9; --green-soft: #193e30; --red: #ffaaa3;
  --lime: #304b39; --purple: #c9b0ff; --teal: #70d9d3;
  --good: #7bddad; --good-soft: #193e30; --warn: #f0cd77; --warn-soft: #44391e;
  --bad: #ffaaa3; --bad-soft: #472c30; --bubble: #293844; --chip: #1b2630;
  --pp-ink: #e9eff4; --pp-muted: #acbbc6; --pp-border: #364550;
  --pp-canvas: #101820; --pp-panel: #1b2630;
  background-color: var(--bg); color: var(--text);
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }
html[data-theme="dark"] :is(.card, .service-tile, .steps article, .everyday, .final-cta, .benefit-band, .service-card, .price-card, .panel, .notice, .pp-topbar) {
  background: var(--card); color: var(--text); border-color: var(--line);
}
html[data-theme="dark"] :is(input, select, textarea) {
  background-color: var(--bg); color: var(--text); border-color: var(--line);
}
html[data-theme="dark"] :is(.brand-name, .menu-heading h1, .service-title, .service-name, .muted) { color: var(--text); }
html[data-theme="dark"] :is(.service-description, .availability-note) { color: var(--muted); }
html[data-theme="dark"] .icon-wrap { background: #30294a; color: #d3c2ff; }
html[data-theme="dark"] .prices-action { background: #30294a; color: #e3d6ff; border-color: #7e6aa9; }
html[data-theme="dark"] :is(.primary, .button.primary) { color: #10251a; }
html[data-theme="dark"] :is(.secondary, .estimate, .choice, .account-card, .package-card[open], .services-card[open], .service-grid a, .service-shortcuts a) {
  background: var(--card); color: var(--text); border-color: var(--line);
}
html[data-theme="dark"] .choice:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); }
html[data-theme="dark"] .estimate-label { color: var(--muted); }
html[data-theme="dark"] .page-control { background: var(--card); }
html[data-theme="dark"] :is(.choice.selected strong, .choice.selected small, .choice.selected span:not(.swatch)) { color: var(--primary); }
html[data-theme="dark"] .choice.selected { background: var(--primary-soft); }
html[data-theme="dark"] .step.primary { color: #101820; }
html[data-theme="dark"] :is(.paper, .floating-note) { color: #182c27; }
html[data-theme="dark"] .formats span { color: var(--muted); border-color: var(--line); }
html[data-theme="dark"]:has(link[href*="/private/"]) main,
html[data-theme="dark"]:has(link[href*="/studio/style.css"]) :is(header, section) {
  background: var(--card); border-color: var(--line); color: var(--text);
}
html[data-theme="dark"]:has(link[href*="/private/"]) :is(a, .eyebrow) { color: var(--primary); }
html[data-theme="dark"]:has(link[href*="/private/"]) .hint { color: var(--muted); }
html[data-theme="dark"]:has(link[href*="/privacy.css"]) :is(h1, h2, strong, a) { color: var(--primary); }
html[data-theme="dark"]:has(link[href*="/privacy.css"]) :is(.lede, .updated, .site-header nav a, .site-footer) { color: var(--muted); }
html[data-theme="dark"]:has(link[href*="/privacy.css"]) :is(.contents, code) { background: var(--card); border-color: var(--line); }
html[data-theme="dark"] :is(.intro, .service-note, .action-note, .final-cta > p:last-child, .use-cases i, .step-tag) { color: var(--muted); }
/* The artwork and document previews keep their real paper/image colors. */
.theme-controls {
  box-sizing: border-box; display: flex; flex: 0 0 auto; clear: both;
  grid-column: 1 / -1; width: 100%; justify-content: flex-start;
  padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.theme-toggle {
  position: static; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: auto; min-width: 112px; min-height: 44px; margin: 0; padding: 9px 14px;
  border: 1px solid #b7c3bd; border-radius: 24px;
  background: #fffef9; color: #183a2d;
  box-shadow: 0 3px 14px #0002; font: 600 13px/1.3 system-ui, sans-serif;
  cursor: pointer; touch-action: manipulation;
}
html[data-theme="dark"] .theme-toggle { background: #24333e; color: #e9eff4; border-color: #607681; }
.theme-toggle:focus-visible { outline: 3px solid #438cce; outline-offset: 3px; }
@media print { .theme-controls { display: none !important; } }

/* Shared dark palette for interactive UI. Document artwork keeps its print colors. */
html[data-theme="dark"] { --purple-dark:#d6c2ff; --lav:#30294a; --mint:#193e30; }
html[data-theme="dark"] :is(input,select,textarea) { caret-color:var(--text); accent-color:var(--primary); }
html[data-theme="dark"] :is(input,textarea)::placeholder { color:#aab9c6; opacity:1; }
html[data-theme="dark"] :is(select option,select optgroup) { background:var(--card); color:var(--text); }
html[data-theme="dark"] :is(button,a,input,select,textarea,summary):focus-visible { outline:3px solid #96baff; outline-offset:3px; }
html[data-theme="dark"] :is(.btn.primary,a.btn.primary,.chip.sel,.exact-cta,.pay,.checkout-progress li.complete .step-marker,.thumb-check,.file-icon:not(.pdf,.word,.excel,.ppt),.devchat .logo) { background:var(--primary); color:#102038; }
html[data-theme="dark"] .pay { color:#102038; }
html[data-theme="dark"] :is(.btn.secondary,.btn.ghost) { background:var(--card); color:var(--text); border-color:var(--line); }
html[data-theme="dark"] :is(.error,[role="alert"]) { color:var(--bad); }
html[data-theme="dark"] :is(.skip,.skip:focus) { background:var(--card); color:var(--primary); }
html[data-theme="dark"] :is(.kiosk-context,.price-note,.stock-note,.basket-foot,.basket-empty,.hero-note) { color:var(--muted); }
html[data-theme="dark"] :is(.order-review-table-wrap,.order-review-table) { background:var(--card); color:var(--text); }
html[data-theme="dark"] .order-review-table :is(thead th,tfoot th,tfoot td) { background:var(--primary-soft); color:var(--text); }
html[data-theme="dark"] :is(.preview-note,.gate-note,.demo-note) { background:var(--warn-soft); color:var(--warn); }
html[data-theme="dark"] :is(.canva-import,.canva-previews,.canva-import .canva-privacy) { background:var(--card); color:var(--text); border-color:var(--line); }
html[data-theme="dark"] .canva-import :is(header small,[data-status],[data-thumbnail-status]) { color:var(--muted); }
html[data-theme="dark"] .canva-import .canva-page:has(input:checked) { background:var(--primary-soft); color:var(--primary); }
html[data-theme="dark"] .canva-page-image { background:var(--bg); color:var(--muted); }
html[data-theme="dark"] .canva-import button.btn { background:var(--primary); color:#102038; }

/* Landing page artwork uses its original ink; surrounding copy follows the theme. */
html[data-theme="dark"]:has(link[href*="/landing/style.css"]) :is(.button.primary,.final-cta .button) { background:#a3dbb9; color:#102a21; }
html[data-theme="dark"] :is(.scene-caption,.scene-spark) { color:#375041; }
html[data-theme="dark"] .printer-brand { color:#203a2b; }
html[data-theme="dark"] .paper :is(em,span) { color:#245d48; }
html[data-theme="dark"] :is(.hero-points span,.service-index i) { color:var(--muted); }
html[data-theme="dark"]:has(link[href*="/privacy.css"]) .eyebrow { color:var(--primary); }
html[data-theme="dark"]:has(link[href*="/customer/style.css"]) :is(.primary,.tabs button[aria-pressed=true]) { background:#a3dbb9; color:#102a21; }
html[data-theme="dark"]:has(link[href*="/customer/style.css"]) #error { background:var(--bad-soft); color:var(--bad); }
html[data-theme="dark"]:has(link[href*="/pricelist/"]) :is(.estimate-mark,.exact-total) { background:var(--primary-soft); color:var(--primary); }
html[data-theme="dark"]:has(link[href*="/pricelist/"]) .estimate span { color:var(--muted); }
html[data-theme="dark"]:has(link[href*="/private/"]) :is(button,.button) { background:var(--primary); color:#102038; }
html[data-theme="dark"]:has(link[href*="/kiosk-display/"]) :is(#connection,#timer) { color:var(--muted); }
html[data-theme="dark"]:has(link[href*="/devchat/"]) .logo { background:var(--primary); color:#102038; }
html[data-theme="dark"] #hotspotApp .ipm-button { background:var(--card); color:var(--text); border-color:var(--line); }

/* Supplies catalog, filters, basket and checkout. */
html[data-theme="dark"]:has(link[href*="/supplies/"]) :is(.hero-panel,.perk,.product,.basket,.no-results,.dialog,.search input) { background:var(--card); color:var(--text); border-color:var(--line); }
html[data-theme="dark"]:has(link[href*="/supplies/"]) :is(.nav,.hero-copy>p:not(.eyebrow),.search span,.basket-remove) { color:var(--muted); }
html[data-theme="dark"]:has(link[href*="/supplies/"]) :is(.filter,.add-button,.qty-control,.qty-control button,.perk-icon) { background:#30294a; color:#e3d6ff; border-color:var(--line); }
html[data-theme="dark"]:has(link[href*="/supplies/"]) :is(.filter[aria-pressed=true],.cart-button,.primary-link,.checkout,.dialog button) { background:#c9b0ff; color:#26143f; }
html[data-theme="dark"]:has(link[href*="/supplies/"]) :is(.cart-count,.product-tag) { color:#26143f; }
html[data-theme="dark"]:has(link[href*="/supplies/"]) .announcement { background:#30294a; }
html[data-theme="dark"]:has(link[href*="/supplies/"]) .status-message { color:#ffb5d2; }
html[data-theme="dark"]:has(link[href*="/hotspot/"]) :is(.brand,.network-badge,.eyebrow,.service-grid svg) { color:var(--purple); }
html[data-theme="dark"]:has(link[href*="/hotspot/"]) :is(.device-code,.print-banner,.service-choice,.outline) { background:var(--card); color:var(--text); border-color:var(--line); }
html[data-theme="dark"]:has(link[href*="/hotspot/"]) .service-choice small { color:var(--muted); }

/* All studios share readable panels, including dynamically rendered controls. */
html[data-theme="dark"]:has(link[href*="/studio/"]) header a { color:var(--primary); }
html[data-theme="dark"]:has(link[href*="/studio/"]) :is(input,select,textarea) { background:var(--bg); color:var(--text); border-color:var(--line); }
html[data-theme="dark"] .poster-price-review :is(details,.poster-estimate-total) { background:var(--bg); color:var(--text); border-color:var(--line); }
html[data-theme="dark"] .poster-price-review details summary { color:var(--text); }
html[data-theme="dark"] body.rush-id-page { --rid-ink:#e9eff4; --rid-muted:#b5c2ce; --rid-line:#40525e; --rid-accent:#8cddbd; }
html[data-theme="dark"] .rush-id-page :is(.rid-secondary,.rid-quiet,.rid-photo,.rid-photo-card,.rid-sheet,.rid-edit-controls,.rid-photo-edit-controls,.rid-quality-panel,.rid-quality-panel li,.rid-rate-note,.rid-pdf-review .rid-estimate,.rid-mini-sheet-list>span) { background:var(--card); color:var(--text); border-color:var(--line); }
html[data-theme="dark"] .rush-id-page :is(header #back,#status,.rid-settings-grid label,.rid-edit-controls label,.rid-template-head>label,.rid-sheet-template,.rid-tag-choice,.rid-price-row,.rid-price-footer,.rid-live-pill,.rid-accept-check,.rid-pdf-review summary,.rid-person-pricing label,.rid-clean-toggle,.rid-quality-panel li span,.rid-photo-edit-controls label,.rid-photo-edit-controls .rid-photo-edit-note) { color:var(--rid-muted); }
html[data-theme="dark"] .rush-id-page :is(.rid-primary,.rid-upload-button) { background:#8cddbd; color:#102a21; }
html[data-theme="dark"] .rush-id-page :is(.rid-primary:hover,.rid-upload-button:hover) { background:#a3ebca; }
html[data-theme="dark"] .rush-id-page :is(.rid-photo.is-active,.rid-mini-sheet-list>span.is-active,.rid-step-title>span,.rid-photo i) { background:#193e30; color:#a3ebca; }
html[data-theme="dark"] .rush-id-page :is(.rid-remove-photo,.rid-remove-sheet,.rid-photo-edit-close) { background:var(--card); color:#ffbaa5; }
html[data-theme="dark"] .rush-id-page #status.error { color:var(--bad); }
html[data-theme="dark"] body.photopaper-studio { --pp-ink:#e9eff4; --pp-muted:#b5c2ce; --pp-border:#40525e; --pp-canvas:#101820; --pp-panel:#1b2630; --pp-purple:#c9b0ff; }
html[data-theme="dark"] .photopaper-studio :is(.pp-workspace,.pp-tool-rail,.pp-left-panel,.pp-inspector,.pp-canvas-toolbar,.pp-canvas-footer,.pp-page-thumbs,.pp-pdf-review,.pp-empty,.pp-layout-option,.pp-preflight-card) { background:var(--card); color:var(--text); border-color:var(--line); }
html[data-theme="dark"] .photopaper-studio :is(.pp-back,.pp-save-state,#status,.pp-rail-item,.pp-panel-title>a,.pp-field,.pp-field small,.pp-crop label,.pp-inspector-heading>span,.pp-sheet-wrap>small) { color:var(--pp-muted); }
html[data-theme="dark"] .photopaper-studio #status { background:var(--bg); }
html[data-theme="dark"] .photopaper-studio #status.error { color:var(--bad); }
html[data-theme="dark"] .photopaper-studio :is(.pp-top-secondary,.pp-upload-button,.pp-autofill,.pp-layout-icon,.pp-page-nav button,.pp-page-thumbs button,.pp-selection-actions button,.pp-preflight-card button,.pp-pdf-review .secondary) { background:#30294a; color:#e3d6ff; border-color:#75628f; }
html[data-theme="dark"] .photopaper-studio :is(.pp-rail-item.active,.pp-layout-option.selected,.pp-package-summary) { background:#30294a; color:#e3d6ff; }
html[data-theme="dark"] .photopaper-studio :is(.pp-package-summary strong,.pp-empty>span) { color:#d6baff; }
html[data-theme="dark"] .photopaper-studio :is(.pp-top-primary,.pp-pdf-review button:not(.secondary)) { background:#c9b0ff; color:#26143f; }
html[data-theme="dark"] .photopaper-studio .pp-canvas-scroll { background-color:var(--bg); background-image:radial-gradient(#364550 .7px,transparent .7px); }
html[data-theme="dark"] .photopaper-studio .pp-preflight-card p { color:var(--good); }
html[data-theme="dark"] .photopaper-studio .pp-preflight-card p.warn { color:var(--warn); }
/* Captions belong to the printed page rather than the editor theme. */
html[data-theme="dark"] .photopaper-studio .pp-caption { background:#fffdf2; color:#302e35; }
html[data-theme="dark"] .benefits span { color:var(--muted); }
html[data-theme="dark"] .floating-note span { color:#245d48; }
html[data-theme="dark"] :is(#estimateContext,.service-total) { color:var(--muted); }
html[data-theme="dark"] .service-total { background:var(--primary-soft); border-color:var(--line); }
html[data-theme="dark"]:has(link[href*="/pricelist/"]) .local-price-entry .local-price-button { background:var(--primary-soft); color:var(--primary); border-color:var(--line); }
html[data-theme="dark"] #hotspotApp .ipm-button-primary { background:#6439d1; color:#fff; }
html[data-theme="dark"] #hotspotApp .ipm-button-danger { color:var(--bad); }

html[data-theme="dark"] .photopaper-studio .pp-brand-mark { background:#c9b0ff; color:#26143f; }
html[data-theme="dark"] .photopaper-studio .pp-top-primary:hover { background:#ddcaff; }
html[data-theme="dark"]:has(link[href*="/supplies/"]) :is(.book-icon,.pencil-cup) { color:#26143f; }
html[data-theme="dark"] #printGroups a.btn { color:#102038; }
html[data-theme="dark"] .rush-id-page .rid-pdf-review { background:var(--card); color:var(--text); border-color:var(--line); }
html[data-theme="dark"]:has(link[href*="/webview/"]) :is(.btn:not(.secondary),.pay) { background:var(--primary); color:#102038; }
html[data-theme="dark"] .canva-import header { background:var(--card); color:var(--text); border-color:var(--line); }
/* Standalone maintenance, email review and demo checkout pages. */
html[data-theme="dark"] .theme-message { color:var(--text) !important; }
html[data-theme="dark"] .theme-message :is(main,.card) { background:var(--card); color:var(--text); }
html[data-theme="dark"] .theme-message :is(p,.hint,label) { color:var(--muted); }
html[data-theme="dark"] .theme-message a { color:var(--primary); }
html[data-theme="dark"] .theme-message.card a { background:var(--primary); color:#102038; }
html[data-theme="dark"] .theme-message button { background:var(--primary); color:#102038; }
html[data-theme="dark"] .theme-message .theme-result { color:var(--bad) !important; }
html[data-theme="dark"] .theme-message .theme-result[data-result="good"] { color:var(--good) !important; }
/* Expandable test notice stays in normal flow to avoid covering controls. */
.diagnostics-notice { margin: 1rem auto; padding: .7rem; max-width: 42rem; font-size: .85rem; border: 1px solid currentColor; border-radius: .5rem; }
.diagnostics-notice summary { cursor: pointer; }
