/* Optional reading palette. Original light design is unchanged. */
html[data-theme="dark"]{color-scheme:dark;--navy:#213b52;--navy2:#30536b;--ink:#e8e4dc;--muted:#b9bebc;--paper:#151e27;--white:#202b36;--line:#3d4750;--gold:#c6aa73}
html[data-theme="dark"] body{background:var(--paper);color:var(--ink)}
html[data-theme="dark"] .site-header,html[data-theme="dark"] .catalog-card,html[data-theme="dark"] .result{border-color:var(--line)}
html[data-theme="dark"] :is(.stats-band,.search-options,.comparison-note,.compare-note,.catalog-controls,.reader-toolbar,.compare-controls,.institution-bar){background:#202b35;color:#e8e4dc}
html[data-theme="dark"] :is(.search-box,.search-input-row,.catalog-list,.compare-pane,.compare-body,.reader-body,.dialog-content,.modal-content,dialog,.study,.citation,.biblio-table,.policy,.studies){background:var(--white);color:var(--ink)}
html[data-theme="dark"] :is(.result p,.hero-description,.section-heading>p,.stats-inner span,.eyebrow,.small-caps,.book-description,.subtitle,.book-source,.book-meta,.result-locus,.search-note,.catalog-filter,.compare-source-note,.header-languages,.study dt,.study dd,.policy p,.biblio-intro,.search-options label,.search-language-note,.examples,.search-destinations,.search-status){color:#c5c8c5}
html[data-theme="dark"] :is(.hero h1,h1,h2,h3,.wordmark-name,.study h2,.studies h1,.policy h1,.policy h2,.bibliography h1,.result h3){color:#f1ede4}
html[data-theme="dark"] :is(input,select,textarea){background:#26333e;color:#f1ede4;border-color:#53606b}
html[data-theme="dark"] :is(input,textarea)::placeholder{color:#aeb7ba}
html[data-theme="dark"] :is(.button.primary,.primary){background:#395b75;color:#fff}
html[data-theme="dark"] :is(.outline,.button.outline){color:#ebe4d8;border-color:#889198}
html[data-theme="dark"] :is(.search-input-row input){background:transparent}
html[data-theme="dark"] .search-options{border-color:#53606b}
html[data-theme="dark"] .result mark,html[data-theme="dark"] mark{background:#806626;color:#fff9de}
html[data-theme="dark"] :is(#latin-gloss,#latin-suggest){background:#202b35!important;color:#eee9df!important;border-color:#64717b!important}
html[data-theme="dark"] #latin-gloss a{color:#d8bd86}
html[data-theme="dark"] #latin-suggest button{color:#eee9df!important;border-color:#4c5762!important}
html[data-theme="dark"] .hero-book-pair:after{background:linear-gradient(#25303a,#151e27)}
html[data-theme="dark"] .hero-book-pair{border-color:#65717b}
html[data-theme="dark"] .edition-date{background:#293640;color:#e9e2d6}
html[data-theme="dark"] .compare-pane iframe,html[data-theme="dark"] .reader-body iframe{color-scheme:light}
html[data-theme="dark"] .theme-switch{border-color:#889198;color:#e9e3d8}
.theme-switch{display:inline-flex;gap:6px;align-items:center;font-size:11px;font-weight:600;white-space:nowrap;border:1px solid var(--line);padding:6px 10px;margin-left:10px;background:transparent;color:var(--ink);border-radius:2px}
.theme-switch:hover{border-color:var(--gold)}

/* Theme control always remains in the header, including narrow layouts. */
.header-inner{flex-wrap:wrap;gap:16px}.header-inner nav{min-width:0;flex:1 1 440px;flex-wrap:wrap}.header-inner .theme-switch{display:inline-flex!important;visibility:visible!important;flex:0 0 auto;position:relative;min-width:90px;min-height:38px;justify-content:center;margin-left:auto;cursor:pointer;color:var(--ink);font:600 13px Arial,sans-serif}.header-inner .header-languages{flex:0 1 auto}html[data-theme="dark"] :is(.scholarly-text,.scholarly-panel,.dictionary-entry,.dictionary-entry h3,.passage-toolbar strong,.reader-hit,.reader-intro){color:var(--ink)}html[data-theme="dark"] :is(.dictionary-entry,.scholarly-panel){background:var(--paper)}html[data-theme="dark"] :is(.dictionary-entry .source,.scholarly-panel .source,.source-links,.provenance){color:var(--muted)}.theme-switch:focus-visible{outline:3px solid var(--gold);outline-offset:3px}
@media(max-width:760px){.header-inner nav{flex-basis:100%;order:3}.header-inner .wordmark{max-width:65%}.header-inner .theme-switch{order:2}.header-inner .header-languages{margin-left:auto}.header-inner{padding-top:18px;padding-bottom:18px}}

html[data-theme="dark"] :is(a,.examples button,.search-destinations button,.text-link,.site-header nav button){color:var(--ink)}
html[data-theme="dark"] :is(.result-meta,.book-source,.export-tools label){color:var(--muted)}
html[data-theme="dark"] .button.primary{color:white}

/* Scriptorium H: readable light surfaces when global dark theme is active. */
html[data-theme="dark"] .notice,
html[data-theme="dark"] #h-display-controls,
html[data-theme="dark"] #folio-identification,
html[data-theme="dark"] #image-mode {
  background:#efe8db!important;
  color:#192b3c!important;
  border-color:#b69a69!important;
}
html[data-theme="dark"] .notice *,
html[data-theme="dark"] #h-display-controls *,
html[data-theme="dark"] #folio-identification *,
html[data-theme="dark"] #image-mode :is(legend,label,span,strong,output) {
  color:#192b3c!important;
}
html[data-theme="dark"] #h-display-controls button,
html[data-theme="dark"] #image-mode button {
  background:#fffdf8!important;
  color:#192b3c!important;
  border:1px solid #a78b5d!important;
}
html[data-theme="dark"] #image-mode button[aria-pressed="true"] {
  background:#20354b!important;color:#fff!important;
}
html[data-theme="dark"] #h-display-controls input[type="range"]{accent-color:#557aa6}

/* Pale cards retain ink-dark text in dark theme. */
html[data-theme="dark"] .h-cotejo-link,
html[data-theme="dark"] .h-cotejo-link :is(a,strong,small,span){
 color:#172b3c!important;
}
html[data-theme="dark"] .h-cotejo-link a:hover,
html[data-theme="dark"] .h-cotejo-link a:focus-visible{
 color:#365b79!important;text-decoration:underline;
}


/* Contraste accesible para listas de libros y capítulos en modo oscuro.
   Corrige menús nativos con texto claro sobre fondo blanco, y paneles
   de consulta con fondo blanco heredado. Modo claro intacto. */
html[data-theme="dark"] :is(
  #book,#chapter,#section,#index-book,#codex-book,
  #find-scope,#critical-edition,#critical-mode,
  .scholarly-controls select,.critical-form select
){
  background-color:#243746!important;
  color:#fff3dc!important;
  border:1px solid #a6b6c4!important;
  color-scheme:dark;
}
html[data-theme="dark"] select :is(option,optgroup){
  background-color:#243746!important;
  color:#fff3dc!important;
}
html[data-theme="dark"] select option:disabled{
  background-color:#243746!important;
  color:#b4c0c9!important;
}
html[data-theme="dark"] :is(.critical-form,.critical-parallel-edition){
  background-color:#263845!important;
  color:#f1ede4!important;
  border-color:#65717b!important;
}
html[data-theme="dark"] :is(.critical-form,.critical-parallel-edition) :is(h2,h3,h4,label,p,strong){
  color:#f1ede4;
}

/* Cross-library locus navigation: never allow light-on-light labels. */
html[data-theme="dark"] :is(#place-loci,#dossier-loci,.loci-list,.locus-links,.index-loci,.locus-pills) a {
 background:#213b50!important;color:#f9ecd2!important;border-color:#d0b585!important;text-decoration:underline;text-decoration-color:#bda87d;
}
html[data-theme="dark"] :is(#place-loci,#dossier-loci,.loci-list,.locus-links,.index-loci,.locus-pills) a:hover,
html[data-theme="dark"] :is(#place-loci,#dossier-loci,.loci-list,.locus-links,.index-loci,.locus-pills) a:focus-visible {
 background:#e4c997!important;color:#152d41!important;outline:2px solid #ae8f5c;
}
html:not([data-theme="dark"]) :is(#place-loci,#dossier-loci,.loci-list,.locus-links,.index-loci,.locus-pills) a {
 background:#faf5e9;color:#183a52;border-color:#ad946f;
}

/* Native dropdown options: operating-system menus must not render white labels on white. */
html[data-theme="dark"] select {color-scheme:dark!important;background-color:#263d50!important;color:#f8f0e6!important;}
html[data-theme="dark"] select option,html[data-theme="dark"] select optgroup {background-color:#263d50!important;color:#f8f0e6!important;}
html:not([data-theme="dark"]) select option,html:not([data-theme="dark"]) select optgroup {background-color:#fffdf8!important;color:#1b3345!important;}

/* Unified academic theme icon, consistent with Vitruvia. */
.theme-switch,.header-inner .theme-switch,.research-nav-controls .theme-switch,.research-nav-inner .theme-switch{
 display:inline-flex!important;align-items:center!important;justify-content:center!important;
 flex:0 0 42px!important;width:42px!important;min-width:42px!important;height:42px!important;min-height:42px!important;
 padding:0!important;margin-left:8px;border-radius:11px!important;
 border:1px solid #b5b8b7!important;background:#f2f1ed!important;color:#24313a!important;
 font-size:0!important;line-height:1!important;box-shadow:none!important;
 transition:background .2s ease,border-color .2s ease!important;
}
.theme-switch svg{width:19px;height:19px;display:block;flex:none}
.theme-switch:hover,.theme-switch:focus-visible{background:#e1e2df!important;border-color:#77838b!important}
html[data-theme="dark"] .theme-switch{background:#1b2833!important;border-color:#586470!important;color:#e8e8e8!important}
html[data-theme="dark"] .theme-switch:hover{background:#344553!important}
.theme-switch:focus-visible{outline:2px solid #b49a65!important;outline-offset:3px}
@media(max-width:760px){.theme-switch,.header-inner .theme-switch{width:42px!important;min-width:42px!important;flex-basis:42px!important}}


/* Shared accessibility and responsive polish — November 2026. */
.library-skip-link{position:fixed;z-index:100000;left:12px;top:12px;transform:translateY(-180%);
 background:var(--paper,#fff);color:var(--ink,#172b3c);border:2px solid var(--gold,#ad925c);
 border-radius:7px;padding:12px 16px;font:600 14px/1.4 Arial,sans-serif;
 text-decoration:none;box-shadow:0 8px 24px #0004}
.library-skip-link:focus{transform:translateY(0)}
main:focus{outline:none}
:where(main,article,.reader-body,.compare-body,.bibliography,.studies) :is(p,li,blockquote){
 overflow-wrap:break-word;word-break:normal;hyphens:auto}
:where(main,article,.reader-body) :is(img,video,canvas,iframe){max-width:100%}
:where(main,article,.reader-body) img{height:auto}
:where(main,article,.reader-body) :is(pre,table){max-width:100%}
:where(main,article,.reader-body) pre{overflow-x:auto}
@media(max-width:760px){:where(main,article,.reader-body) table{display:block;overflow-x:auto}}
:where(button,a,input,select,textarea,summary):focus-visible{outline:2px solid var(--gold,#b99d68);outline-offset:3px}
@media(max-width:760px){
 :where(main,article,.reader-body) :is(h1,h2,h3){overflow-wrap:break-word}
 :where(main,article,.reader-body) :is(input,textarea,select){max-width:100%}
 .theme-switch.theme-floating{right:12px!important;top:12px!important}
}
@media(prefers-reduced-motion:reduce){
 *,*::before,*::after{scroll-behavior:auto!important;animation-duration:.01ms!important;
 animation-iteration-count:1!important;transition-duration:.01ms!important}
}
