/* ApexCMS v2.1.156 — Corrected premium dark mode for public tool pages.
   Safety principle: preserve each tool's own component/theme CSS and enhance only
   shared dark-mode rendering. No wildcard card/header/panel restyling and no global
   !important surface replacement. */

:root[data-theme="dark"]{color-scheme:dark}
html.apex-tool-theme-preboot-v21156[data-theme="dark"],
html.apex-tool-theme-preboot-v21156[data-theme="dark"] body{background-color:#07111f}
html.apex-tool-theme-preboot-v21156 *,
html.apex-tool-theme-preboot-v21156 *::before,
html.apex-tool-theme-preboot-v21156 *::after{transition:none!important}

/* Phase 3 tools used a separate purple-black palette. Bring only their design tokens
   into the same deep navy family as Invoice & Receipt Data Extractor while retaining
   their original component layout, gradients and accent colors. */
:root[data-theme="dark"] body[data-apex-phase3-tool]{
  --bg:#07111f;
  --panel:rgba(13,29,49,.92);
  --panel2:#10243b;
  --text:#eef6ff;
  --muted:#93a9bd;
  --line:rgba(155,190,222,.16);
  --shadow:0 25px 80px rgba(0,0,0,.34);
}

/* Generic/fallback tool shell uses these tokens. Dedicated tools continue using
   their own existing variables and dark-theme rules. */
:root[data-theme="dark"] body[data-apex-tool-slug] .workspace,
:root[data-theme="dark"] body[data-apex-tool-slug] .box,
:root[data-theme="dark"] body[data-apex-tool-slug] .related-card{
  border-color:var(--border,rgba(155,190,222,.16));
}

/* Native form/UI finishing. These rules do not replace component backgrounds;
   they only fix browser-native pieces that frequently stay white in dark mode. */
:root[data-theme="dark"] body[data-apex-tool-slug] :where(input,select,textarea,button){color-scheme:dark}
:root[data-theme="dark"] body[data-apex-tool-slug] :where(select option,select optgroup){
  color:#eef6ff;
  background:#10243b;
}
:root[data-theme="dark"] body[data-apex-tool-slug] :where(input,textarea)::placeholder{
  color:color-mix(in srgb,currentColor 58%,transparent);
  opacity:1;
}
:root[data-theme="dark"] body[data-apex-tool-slug] input:-webkit-autofill,
:root[data-theme="dark"] body[data-apex-tool-slug] input:-webkit-autofill:hover,
:root[data-theme="dark"] body[data-apex-tool-slug] input:-webkit-autofill:focus{
  -webkit-text-fill-color:#eef6ff;
  caret-color:#eef6ff;
  transition:background-color 9999s ease-out 0s;
}
:root[data-theme="dark"] body[data-apex-tool-slug] :where(button,a,input,select,textarea,summary):focus-visible{
  outline:3px solid color-mix(in srgb,var(--a1,var(--ire-a1,#60a5fa)) 38%,transparent);
  outline-offset:3px;
}

/* Dialog/popover surfaces are browser-native on a few tools and need a safe dark fallback. */
:root[data-theme="dark"] body[data-apex-tool-slug] dialog{
  color:#eef6ff;
  background:#0d1d31;
  border-color:rgba(155,190,222,.18);
}
:root[data-theme="dark"] body[data-apex-tool-slug] dialog::backdrop{
  background:rgba(2,8,15,.72);
  backdrop-filter:blur(4px);
}

/* Sharp, restrained scrollbars; component colors are otherwise untouched. */
:root[data-theme="dark"] body[data-apex-tool-slug]{scrollbar-color:#38516b #07111f}
:root[data-theme="dark"] body[data-apex-tool-slug] *::-webkit-scrollbar{width:10px;height:10px}
:root[data-theme="dark"] body[data-apex-tool-slug] *::-webkit-scrollbar-track{background:#07111f}
:root[data-theme="dark"] body[data-apex-tool-slug] *::-webkit-scrollbar-thumb{
  background:#38516b;
  border:2px solid #07111f;
  border-radius:999px;
}
:root[data-theme="dark"] body[data-apex-tool-slug] *::-webkit-scrollbar-thumb:hover{background:#4d6a87}

/* Selection and media remain natural; never filter logos, previews, canvases or images. */
:root[data-theme="dark"] body[data-apex-tool-slug] ::selection{background:rgba(96,165,250,.34);color:#fff}
:root[data-theme="dark"] body[data-apex-tool-slug] :where(img,canvas,video,iframe){filter:none;image-rendering:auto}

@media(prefers-reduced-motion:reduce){
  html.apex-tool-theme-preboot-v21156 *,
  html.apex-tool-theme-preboot-v21156 *::before,
  html.apex-tool-theme-preboot-v21156 *::after{transition:none!important}
}
