/* Opt-in color customization. The pre-existing reading-options layer stays
   first, so its High Contrast !important declarations remain authoritative. */
@layer ar-reading-options69, ar-color-preferences;

/* Keep the original gear and its close/keyboard behavior. Only its contents
   grow; the open panel scrolls within the viewport on desktop and mobile. */
html body #ar-cyber-customize-panel {
 width:min(340px,calc(100vw - 32px));max-width:calc(100vw - 32px)!important;
 max-height:min(720px,calc(100dvh - 100px));overflow-y:auto;overscroll-behavior:contain;
 scrollbar-gutter:stable;gap:10px;
}
html body #ar-cyber-customize-panel .ar-color-field {display:block;min-width:0;margin:0;padding:9px 0 0;border:0;border-top:1px solid currentColor}
html body #ar-cyber-customize-panel .ar-color-field[hidden],html body #ar-cyber-accent-label[hidden] {display:none!important}
html body #ar-cyber-customize-panel :is(.ar-color-field legend,.ar-color-label) {float:none;width:auto;margin:0 0 7px;padding:0;font:650 12px/1.45 system-ui,sans-serif!important;letter-spacing:.015em;text-transform:none;color:inherit!important}
html body #ar-cyber-customize-panel .ar-color-options {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
html body #ar-cyber-customize-panel .ar-color-options button {display:flex;align-items:center;justify-content:flex-start;gap:7px;box-sizing:border-box;min-width:0;min-height:38px!important;height:auto;padding:7px 8px!important;margin:0;border:1px solid #87745b!important;border-radius:6px!important;background:#211a13!important;color:#f4ecdf!important;clip-path:none!important;box-shadow:none!important;text-align:left;white-space:normal!important;font:500 11px/1.35 system-ui,sans-serif!important;letter-spacing:0!important;text-transform:none;cursor:pointer;overflow-wrap:anywhere}
html body #ar-cyber-customize-panel .ar-color-options button::before,html body #ar-cyber-customize-panel .ar-color-options button::after {content:none!important}
html body #ar-cyber-customize-panel .ar-color-options [data-ar-color-swatch] {flex:0 0 12px;width:12px;height:12px;border:1px solid #fff7;border-radius:50%;box-sizing:border-box}
html body #ar-cyber-customize-panel .ar-color-options button[aria-checked="true"] {border-color:#edcf9c!important;box-shadow:inset 0 0 0 1px #edcf9c!important;background:#3b2d1e!important;font-weight:750!important}
html body #ar-cyber-customize-panel .ar-color-options button:focus-visible,html body #ar-cyber-customize-panel #ar-color-reset:focus-visible {outline:3px solid #f5dfbc!important;outline-offset:2px!important}
html body #ar-cyber-customize-panel :is(.ar-color-note,#ar-color-reset) {margin:0;font:400 11px/1.55 system-ui,sans-serif!important;letter-spacing:0;text-transform:none;color:inherit}
html body #ar-cyber-customize-panel #ar-color-status:empty {display:none}
html body #ar-cyber-customize-panel #ar-color-reset {display:block;width:100%;min-height:38px;padding:7px 10px;border:1px solid currentColor;border-radius:6px;clip-path:none!important;background:transparent;color:inherit!important;text-align:center;cursor:pointer}
html body #ar-cyber-customize-panel #ar-color-reset::before,html body #ar-cyber-customize-panel #ar-color-reset::after {content:none!important}
html body #ar-cyber-customize-panel #ar-cyber-palette {margin-top:0}
/* Unselected backgrounds keep each original theme's own restrained palette. */
html body.ar-monochrome #ar-cyber-customize-panel .ar-color-options button {background:#1c1c1c!important;color:#ededed!important;border-color:#777!important}
html body.ar-monochrome #ar-cyber-customize-panel .ar-color-options button[aria-checked="true"] {background:#30302f!important;border-color:var(--ar-colors-accent,#c9c9c9)!important;box-shadow:inset 0 0 0 1px var(--ar-colors-accent,#c9c9c9)!important}
html body.ar-cyber #ar-cyber-customize-panel .ar-color-options button {background:#07090b!important;color:#e9edf0!important;border-color:var(--cyber-line,#777)!important}
html body.ar-cyber #ar-cyber-customize-panel .ar-color-options button[aria-checked="true"] {background:var(--cyber-deep,#101113)!important;border-color:var(--cyber-bright,#ddd)!important;box-shadow:inset 0 0 0 1px var(--cyber-bright,#ddd)!important}
html body:is(.ar-monochrome,.ar-cyber) #ar-cyber-customize-panel :is(.ar-color-options button,#ar-color-reset):focus-visible {outline-color:var(--cyber-bright,var(--ar-colors-accent,#ededed))!important}
@media(max-width:900px){html body #ar-cyber-customize-panel {width:min(340px,calc(100vw - 40px));max-height:65dvh}}
@media(pointer:coarse){html body #ar-cyber-customize-panel :is(.ar-color-options button,#ar-color-reset) {min-height:44px!important}}

@layer ar-color-preferences {
 @media(forced-colors:none) {
  /* Accent is an outline/text token, deliberately independent of surface fill.
     Do not redefine Cyber's palette variables or recolor its native assets. */
  body[data-ar-accent-custom]:not(.ar-cyber),
  body[data-ar-accent-custom]:not(.ar-cyber) :is(.fs-study,.fs-card,.fs-guide,.fs-banner,.people-tool,.aff-dashboard) {
   --gold:var(--ar-colors-accent)!important;--gold2:var(--ar-colors-accent)!important;--gold-light:var(--ar-colors-accent)!important;--fs-accent:var(--ar-colors-accent)!important;
   --library-gold:var(--ar-colors-accent)!important;--library-line:var(--ar-colors-line)!important;--line:var(--ar-colors-line)!important;
   --library-color-e5be7d:var(--ar-colors-accent);--library-color-edc98c:var(--ar-colors-accent);--library-color-f6d9a5:var(--ar-colors-accent);
   --library-color-f3ca85:var(--ar-colors-accent);--library-color-c49a5f:var(--ar-colors-accent);--library-color-ac8b5d:var(--ar-colors-line);--library-color-886e4b:var(--ar-colors-line);--library-color-8c704b:var(--ar-colors-line);--library-color-7c603d:var(--ar-colors-line);
  }
  body[data-ar-accent-custom]:not(.ar-cyber) :is(.eyebrow,.section-kicker,.card-category,.support-label,.ar-discovery-kicker,.ar-result-kind,#breadcrumb,.ar-dashboard-icon,.ar-dashboard-chevron,.ar-route-chevron,.ar-route-number,.fs-card-meta,.study-select-group) {color:var(--ar-colors-accent)!important}
  body[data-ar-accent-custom]:not(.ar-cyber) :is(.outline-button,.quiet-button,.gold-button,.tree-item,.page-tab,.study-select-trigger,.ar-select-trigger,.ar-deep-tool,.reading-card,.reading-console,.fs-card,.featured-card,.library-card,.tool-card,summary):not(:where(#ar-avdi-cage *,#ar-companion-dock *,#ar-avdi-companion *,#ar-azeroth-cameo *)) {border-color:var(--ar-colors-line)!important}
  body[data-ar-accent-custom]:not(.ar-cyber) :is(button,a,input,select,textarea,summary):focus-visible:not(:where(#ar-avdi-cage *,#ar-companion-dock *,#ar-avdi-companion *,#ar-azeroth-cameo *)) {outline-color:var(--ar-colors-accent)!important}
  body[data-ar-accent-custom]:not(.ar-cyber) #ar-library-hero #search-form > button {color:var(--ar-colors-on-accent)!important}
  body[data-ar-background-custom],:root[data-ar-background-custom] {background:var(--ar-colors-base)!important;color:var(--ar-colors-ink)!important;color-scheme:var(--ar-colors-scheme)!important;--page:var(--ar-colors-base)!important;--surface:var(--ar-colors-surface)!important;--surface-raised:var(--ar-colors-raised)!important;--surface-warm:var(--ar-colors-raised)!important;--text:var(--ar-colors-ink)!important;--muted:var(--ar-colors-muted)!important}
  body[data-ar-background-custom] :is(#workspace,#sidebar,.app-shell,.workspace-panel,#ar-embed-scroll) {background-color:var(--ar-colors-base)!important;background-image:none!important;color:var(--ar-colors-ink)!important}
  body[data-ar-background-custom]:not([data-ar-colors-measuring]) [data-ar-color-surface] {background:linear-gradient(165deg,color-mix(in srgb,var(--ar-colors-surface),white 3%),color-mix(in srgb,var(--ar-colors-surface),black 8%))!important;border-color:var(--ar-colors-line)!important;box-shadow:inset 0 1px 0 #ffffff08,0 3px 14px #00000012!important}
  body[data-ar-background-custom]:not([data-ar-colors-measuring]) [data-ar-color-surface="base"] {background:var(--ar-colors-base)!important}
  body[data-ar-background-custom]:not([data-ar-colors-measuring]) [data-ar-color-surface="raised"] {background:linear-gradient(165deg,color-mix(in srgb,var(--ar-colors-raised),white 2%),color-mix(in srgb,var(--ar-colors-raised),black 6%))!important}
  body[data-ar-background-custom]:not([data-ar-colors-measuring]) [data-ar-color-surface]:is(button,a,summary,[role="button"],[role="option"],[role="tab"]):is(:hover,:focus-visible) {background:var(--ar-colors-hover)!important}
  body[data-ar-background-custom]:not([data-ar-colors-measuring]) [data-ar-color-surface]:is(.active,.current,[aria-selected="true"],[aria-checked="true"],[aria-pressed="true"],[aria-current="page"]) {background:var(--ar-colors-selected)!important;border-color:var(--ar-colors-accent)!important;box-shadow:inset 0 0 0 1px var(--ar-colors-accent)!important}
  /* Group 5's three Browse-current controls keep their accepted outline-only
     state in Default/Grim, including hover. Focus retains its separate ring. */
  body[data-ar-background-custom]:not(.ar-cyber) #sidebar #study-tree button.study-directory-button[data-library-mode][aria-current="page"] {background:transparent!important;border-color:var(--ar-colors-accent)!important;box-shadow:inset 0 0 0 1px var(--ar-colors-accent)!important}
  body[data-ar-background-custom]:not([data-ar-colors-measuring]):not([data-reading-contrast="high"]) [data-ar-color-text] {color:var(--ar-color-text)!important;-webkit-text-fill-color:var(--ar-color-text)!important;text-shadow:none!important}
  body[data-ar-background-custom]:not([data-ar-colors-measuring]):not([data-reading-contrast="high"]) [data-ar-color-text]::placeholder {color:var(--ar-color-placeholder)!important;-webkit-text-fill-color:var(--ar-color-placeholder)!important;opacity:1!important}
  body[data-ar-background-custom]:not([data-ar-colors-measuring]):not([data-reading-contrast="high"]) [data-ar-color-photo-text] {text-shadow:0 1px 3px #000b!important}
  body[data-ar-background-custom]:not([data-ar-colors-measuring]):not([data-reading-contrast="high"]) [data-ar-color-before]::before {color:var(--ar-color-before)!important;-webkit-text-fill-color:currentColor!important;text-shadow:none!important;opacity:1!important}
  body[data-ar-background-custom]:not([data-ar-colors-measuring]):not([data-reading-contrast="high"]) [data-ar-color-after]::after {color:var(--ar-color-after)!important;-webkit-text-fill-color:currentColor!important;text-shadow:none!important;opacity:1!important}
  body[data-ar-background-custom]:not([data-ar-colors-measuring]) [data-ar-color-opacity] {opacity:1!important}
  body[data-ar-background-custom] :is(button,a,input,select,textarea,summary,[role="option"]):focus-visible {outline-color:var(--ar-colors-accent)!important}
  body[data-ar-background-custom] :is(button,input,select,textarea):disabled,body[data-ar-background-custom] [aria-disabled="true"] {cursor:not-allowed!important;border-style:dashed!important}
  body[data-ar-background-custom] :is(input,select,textarea) {caret-color:var(--ar-colors-accent)!important}
  body[data-ar-background-custom] ::selection {background:var(--ar-colors-selected)!important;color:var(--ar-colors-ink)!important;text-shadow:none!important}
  body[data-ar-background-custom] .words-of-jesus::selection,body[data-ar-background-custom] .words-of-jesus ::selection {color:var(--ar-color-text,var(--ar-colors-ink))!important}
  :root[data-ar-background-custom]::highlight(ar-reader-saved),:root[data-ar-background-custom]::highlight(ar-reader-current) {background-color:var(--ar-colors-selected)!important;color:var(--ar-colors-ink)!important;text-shadow:none!important}
  :root[data-ar-background-custom]::highlight(ar-reader-current) {text-decoration:underline solid var(--ar-colors-accent)}
  body[data-ar-background-custom] .words-of-jesus::highlight(ar-reader-saved),body[data-ar-background-custom] .words-of-jesus::highlight(ar-reader-current),body[data-ar-background-custom] .words-of-jesus *::highlight(ar-reader-saved),body[data-ar-background-custom] .words-of-jesus *::highlight(ar-reader-current) {color:var(--ar-color-text,var(--ar-colors-ink))!important}
  /* Palette previews retain their literal colors. The original selected-ring
     controller and ARVisualMode own all seven Cyber buttons. */
  body[data-ar-background-custom] #ar-cyber-palette button {background:var(--swatch)!important}
  body[data-ar-background-custom] #ar-cyber-palette button[aria-pressed="true"] {outline:2px solid var(--ar-colors-ink)!important;outline-offset:2px}
  body[data-ar-background-custom] #ar-cyber-palette button:focus-visible {outline:3px solid var(--ar-colors-ink)!important;outline-offset:3px}
 }
}
@media(forced-colors:active) {
 html body #ar-cyber-customize-panel .ar-color-options button {background:ButtonFace!important;color:ButtonText!important;border-color:ButtonText!important;forced-color-adjust:auto}
 html body #ar-cyber-customize-panel .ar-color-options button[aria-checked="true"] {border-color:Highlight!important;outline:2px solid Highlight!important;box-shadow:none!important}
 html body #ar-cyber-customize-panel :is(.ar-color-options button,#ar-color-reset):focus-visible {outline:3px solid Highlight!important}
}
@media print {#ar-normal-accent,#ar-color-background,#ar-color-explanation,#ar-color-reset,#ar-color-status,#ar-cyber-accent-label{display:none!important}}

/* Fix 10: Default's selected hue belongs to quiet material/ambient tokens.
   Layout shells are transparent and the reading runner remains neutral black.
   These exact structural surfaces are also excluded from the repaint walker. */
@layer ar-color-preferences {
 @media screen and (forced-colors:none) {
  html:not([data-ar-theme="simple"]):not([data-ar-theme="simple"]):not([data-ar-theme="mono"]):not([data-ar-theme="cyber"])[data-ar-background-custom]:not([data-reading-contrast="high"]),
  html:not([data-ar-theme="simple"]) body:not(.ar-simple):not(.ar-monochrome):not(.ar-cyber)[data-ar-background-custom]:not([data-reading-contrast="high"]){background:#070707!important;}
  html:not([data-ar-theme="simple"]) body:not(.ar-simple):not(.ar-monochrome):not(.ar-cyber):not([data-reading-contrast="high"]) #ar-embed-scroll,
  html:not([data-ar-theme="simple"]) body:not(.ar-simple):not(.ar-monochrome):not(.ar-cyber):not([data-reading-contrast="high"]) #ar-embed-scroll > .app-shell{background:transparent!important;}
  html:not([data-ar-theme="simple"]) body:not(.ar-simple):not(.ar-monochrome):not(.ar-cyber):not([data-reading-contrast="high"]) #ar-embed-scroll > .app-shell > main#workspace > .workspace-panel{background:#070707!important;}
 }
}

/* Batch23 / 20–22. Structural wrappers are not painted control surfaces.
   Keep the full header black; its existing outline/current-page rules own tabs. */
@media screen and (forced-colors:none) {
 @layer ar-simple {
  html body #ar-site-header[data-ar-nav-page="explorer"] {background:#000!important;}
  html[data-ar-theme="simple"] body #ar-site-header[data-ar-nav-page="explorer"] {
   --simple-header:#000;--simple-header-ink:#ededed;--simple-header-selected:#353535;--simple-header-hover:#252525;
  }
 }
 @layer ar-color-preferences {
  html body:not(.ar-simple):not(.ar-cyber):not([data-reading-contrast="high"]) #workspace > .workspace-top,
  html body:not(.ar-simple):not(.ar-cyber):not([data-reading-contrast="high"]) #workspace > .workspace-top > #ar-workspace-actions {
   background:transparent!important;box-shadow:none!important;
  }
  html body:not(.ar-simple):not(.ar-monochrome):not(.ar-cyber)[data-ar-accent-custom]:not([data-reading-contrast="high"]) #workspace > .workspace-panel {
   border-color:var(--ar-colors-line)!important;
  }
  html body:not(.ar-simple):not(.ar-monochrome):not(.ar-cyber)[data-ar-accent-custom]:not([data-reading-contrast="high"]) #panel-welcome :is(#ar-study-shelf,#ar-continue,#ar-shelf-disclosure,#ar-explore-disclosure,.ar-dashboard-icon) {
   border-color:var(--ar-colors-line)!important;
  }
  html body:not(.ar-simple):not(.ar-monochrome):not(.ar-cyber)[data-ar-accent-custom]:not([data-reading-contrast="high"]) #ar-explorer-engraved-sigil svg {
   filter:url(#ar-default-palette-sigil) brightness(.78)!important;
  }
 }
}
/* Hide fixed-palette fields even before the preference controller refreshes. */
html body.ar-monochrome #ar-cyber-customize-panel :is(#ar-normal-accent,#ar-color-background,#ar-cyber-accent-label,#ar-cyber-palette,#ar-cyber-multicolor-row) {display:none!important;}
