/* QUÍMICA V18 · Parte 16
   Auditoría transversal de superficies en modo oscuro.
   Se oscurecen contenedores y controles, no el contenido fotográfico ni las simulaciones externas. */

html[data-theme="dark"] {
  color-scheme: dark;
  --color-page: #091321;
  --color-surface: #101e30;
  --color-surface-soft: #14243a;
  --color-surface-raised: #192d46;
  --color-ink: #e8f0fa;
  --color-ink-soft: #c5d4e5;
  --color-muted: #9aadc4;
  --color-line: #2b405a;
  --color-line-strong: #405873;
}

/* Superficies compartidas que aún conservaban fondos claros codificados. */
html[data-theme="dark"] .button-secondary,
html[data-theme="dark"] .element-display,
html[data-theme="dark"] .table-preview,
html[data-theme="dark"] .table-placeholder,
html[data-theme="dark"] .simulation-viewer,
html[data-theme="dark"] .planned-simulations .lab-card,
html[data-theme="dark"] .periodic-tools input,
html[data-theme="dark"] .periodic-tools select,
html[data-theme="dark"] .element-detail,
html[data-theme="dark"] .gallery-card {
  color: var(--color-ink);
  border-color: var(--color-line);
  background: #122238;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .16);
}
html[data-theme="dark"] .button-secondary:hover { background: #1a3450; border-color: #47708b; }
html[data-theme="dark"] .element-display { border-top-color: #58d6cb; }
html[data-theme="dark"] .element-display .element-symbol { color: #9ce8df; }
html[data-theme="dark"] .element-display .element-number,
html[data-theme="dark"] .element-display .element-name { color: #c0d0e2; }
html[data-theme="dark"] .table-placeholder {
  background-color: #0f1d30;
  background-image: linear-gradient(rgba(92, 205, 198, .055) 1px, transparent 1px), linear-gradient(90deg, rgba(92, 205, 198, .055) 1px, transparent 1px);
}
html[data-theme="dark"] .table-placeholder strong { color: #e3effb; }
html[data-theme="dark"] .table-placeholder p,
html[data-theme="dark"] .element-detail .detail-note,
html[data-theme="dark"] .element-detail .detail-mass,
html[data-theme="dark"] .element-detail .detail-license,
html[data-theme="dark"] .supplemental-heading p,
html[data-theme="dark"] .image-source-note { color: #adbed1; }
html[data-theme="dark"] .detail-caption { color: #d8e5f2; }
html[data-theme="dark"] .detail-symbol-row h3 { color: #eaf2fb; }
html[data-theme="dark"] .detail-symbol-row p { color: #aebfd2; }
html[data-theme="dark"] .detail-category { background: #193b4d; color: #a9e8e1; }
html[data-theme="dark"] .detail-license { border-color: #30465e; }

/* Catálogo periódico: campos, fichas, filtros y familias con tonos oscuros diferenciados. */
html[data-theme="dark"] .periodic-tools label,
html[data-theme="dark"] .periodic-legend,
html[data-theme="dark"] .periodic-intro { color: #afc1d5; }
html[data-theme="dark"] .periodic-tools input,
html[data-theme="dark"] .periodic-tools select,
html[data-theme="dark"] .periodic-controls-v11 input,
html[data-theme="dark"] .periodic-controls-v11 select,
html[data-theme="dark"] .v11-controls-row input,
html[data-theme="dark"] .v11-controls-row select,
html[data-theme="dark"] .v11-compare-selectors select {
  color: #e5eef9;
  border-color: #3b5470;
  background: #0c1a2b;
  color-scheme: dark;
}
html[data-theme="dark"] .periodic-tile,
html[data-theme="dark"] .periodic-workbench .v11-element-tile {
  color: #e4eef9;
  border-color: #354d67;
  background: #172b42;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025), 0 2px 7px rgba(0, 0, 0, .12);
}
html[data-theme="dark"] .periodic-tile .tile-number,
html[data-theme="dark"] .periodic-tile .tile-name,
html[data-theme="dark"] .v11-tile-number,
html[data-theme="dark"] .v11-tile-name,
html[data-theme="dark"] .v11-tile-mass { color: #b0c2d5; }
html[data-theme="dark"] .periodic-tile:hover,
html[data-theme="dark"] .periodic-workbench .v11-element-tile:hover {
  border-color: #5a9a9b;
  background: #1b394e;
}
html[data-theme="dark"] .periodic-tile:focus-visible,
html[data-theme="dark"] .periodic-workbench .v11-element-tile:focus-visible { outline-color: #67d9d0; }
html[data-theme="dark"] .periodic-tile.cat-no-metal,
html[data-theme="dark"] .periodic-workbench .v11-element-tile.cat-no-metal { background: #173b3d; }
html[data-theme="dark"] .periodic-tile.cat-noble,
html[data-theme="dark"] .periodic-workbench .v11-element-tile.cat-noble { background: #1b3457; }
html[data-theme="dark"] .periodic-tile.cat-alkali,
html[data-theme="dark"] .periodic-workbench .v11-element-tile.cat-alkali { background: #49302d; }
html[data-theme="dark"] .periodic-tile.cat-alkaline,
html[data-theme="dark"] .periodic-workbench .v11-element-tile.cat-alkaline { background: #453a25; }
html[data-theme="dark"] .periodic-tile.cat-metalloid,
html[data-theme="dark"] .periodic-workbench .v11-element-tile.cat-metalloid { background: #34402a; }
html[data-theme="dark"] .periodic-tile.cat-halogen,
html[data-theme="dark"] .periodic-workbench .v11-element-tile.cat-halogen { background: #3a2c4b; }
html[data-theme="dark"] .periodic-tile.cat-transition,
html[data-theme="dark"] .periodic-workbench .v11-element-tile.cat-transition { background: #29344a; }
html[data-theme="dark"] .periodic-tile.cat-post-metal,
html[data-theme="dark"] .periodic-workbench .v11-element-tile.cat-post-metal { background: #244137; }
html[data-theme="dark"] .periodic-tile.cat-lanthanoid,
html[data-theme="dark"] .periodic-workbench .v11-element-tile.cat-lanthanoid { background: #49382c; }
html[data-theme="dark"] .periodic-tile.cat-actinoid,
html[data-theme="dark"] .periodic-workbench .v11-element-tile.cat-actinoid { background: #472c38; }
html[data-theme="dark"] .available-label { color: #a9eee0; background: #153a39; }
html[data-theme="dark"] .periodic-scroll { scrollbar-color: #425c76 #14243a; }

/* Ficha del elemento y modelos atómicos V12/V13: completar selectores que faltaban. */
html[data-theme="dark"] .periodic-workbench .v12-atom-card,
html[data-theme="dark"] .periodic-workbench .v13-atom-card,
html[data-theme="dark"] .periodic-workbench .v11-element-detail,
html[data-theme="dark"] .periodic-workbench .v11-fact-box,
html[data-theme="dark"] .periodic-workbench .v11-config-block,
html[data-theme="dark"] .periodic-workbench .v11-quiz-start,
html[data-theme="dark"] .periodic-workbench .v11-quiz-end {
  color: #dce8f5;
  border-color: #304861;
  background: #101f33;
}
html[data-theme="dark"] .periodic-workbench .v12-orbital-meta,
html[data-theme="dark"] .periodic-workbench .v13-orbital-meta,
html[data-theme="dark"] .periodic-workbench .v12-node-controls,
html[data-theme="dark"] .periodic-workbench .v13-node-controls,
html[data-theme="dark"] .periodic-workbench .v12-model-readout,
html[data-theme="dark"] .periodic-workbench .v13-model-readout,
html[data-theme="dark"] .periodic-workbench .v11-fact-box,
html[data-theme="dark"] .periodic-workbench .v11-config-short,
html[data-theme="dark"] .periodic-workbench .v11-config-value {
  color: #b8c9dc;
  border-color: #304861;
  background: #14263d;
}
html[data-theme="dark"] .periodic-workbench .v12-orbital-meta::after,
html[data-theme="dark"] .periodic-workbench .v13-orbital-meta::after { color: #98afc6; }
html[data-theme="dark"] .periodic-workbench .v12-control-sliders label,
html[data-theme="dark"] .periodic-workbench .v13-control-sliders label,
html[data-theme="dark"] .periodic-workbench .v12-node-controls label,
html[data-theme="dark"] .periodic-workbench .v13-node-controls label { color: #c0d0e0; }
html[data-theme="dark"] .periodic-workbench .v11-detail-top,
html[data-theme="dark"] .periodic-workbench .v11-tool-heading,
html[data-theme="dark"] .periodic-workbench .v11-detail-tabs,
html[data-theme="dark"] .periodic-workbench .v11-fact-box,
html[data-theme="dark"] .periodic-workbench .v11-config-short,
html[data-theme="dark"] .periodic-workbench .v11-config-value { border-color: #304861; }
html[data-theme="dark"] .periodic-workbench .v11-predicted-chip { color: #e2caef; background: #32243f; border-color: #634c78; }
html[data-theme="dark"] .periodic-workbench .v11-answer-option.is-correct { color: #c3f3d6; border-color: #397c60; background: #15382e; }
html[data-theme="dark"] .periodic-workbench .v11-answer-option.is-wrong { color: #ffd0c8; border-color: #86534f; background: #412725; }
html[data-theme="dark"] .periodic-workbench .v11-compare-table tbody tr:nth-child(even) { background: #172b42; }
html[data-theme="dark"] .periodic-workbench .v11-compare-table tbody tr:nth-child(odd) { background: #122238; }
html[data-theme="dark"] .periodic-workbench .v11-result-count,
html[data-theme="dark"] .periodic-workbench .v11-table-legend,
html[data-theme="dark"] .periodic-workbench .v11-legend-item,
html[data-theme="dark"] .periodic-workbench .v11-legend-note,
html[data-theme="dark"] .periodic-workbench .v11-result-count { color: #aebfd2; }

/* Biblioteca y tarjetas de contenido. Las imágenes permanecen sin filtros ni recoloreo. */
html[data-theme="dark"] .element-gallery .gallery-card,
html[data-theme="dark"] .gallery-card,
html[data-theme="dark"] .library-reference-card,
html[data-theme="dark"] .library-constant-card {
  color: #dce8f5;
  border-color: #304861;
  background: linear-gradient(145deg, #14263d, #101e31);
}
html[data-theme="dark"] .gallery-copy h4,
html[data-theme="dark"] .library-reference-card h3,
html[data-theme="dark"] .library-reference-card h4 { color: #e7f0fa; }
html[data-theme="dark"] .gallery-copy p,
html[data-theme="dark"] .gallery-copy small,
html[data-theme="dark"] .library-reference-card p { color: #afc0d3; }
html[data-theme="dark"] .library-reference-card details { border-color: #344d68; }
html[data-theme="dark"] .library-reference-card summary { color: #8fe1d8; }
html[data-theme="dark"] .library-reference-card details p { color: #b8c9dc; }

/* Instrumentos y formularios: evita campos claros aislados dentro de tarjetas oscuras. */
html[data-theme="dark"] .settings-field input,
html[data-theme="dark"] .settings-field select,
html[data-theme="dark"] .titration-lab-card input:not([type="range"]),
html[data-theme="dark"] .titration-lab-card select,
html[data-theme="dark"] .library-search input {
  color: #e6effa;
  border-color: #3a5471;
  background: #0c1a2b;
  color-scheme: dark;
}
html[data-theme="dark"] .titration-lab-card .instrument-panel-divider { background: #30465f; }
html[data-theme="dark"] .titration-lab-card .instrument-step-button:hover,
html[data-theme="dark"] .titration-lab-card .instrument-reset-button:hover,
html[data-theme="dark"] .titration-lab-card .instrument-export-button:hover { color: #dff7f4; border-color: #4b7b86; background: #19374b; }
html[data-theme="dark"] .share-status { color: #dffcf6; border-color: #347a79; background: #123a3a; }

/* Recursos visuales y simulaciones: conservar superficies de contenido original. */
html[data-theme="dark"] .v11-element-photo,
html[data-theme="dark"] .detail-image-wrap,
html[data-theme="dark"] .gallery-image-wrap { background: #f3f6f7; }
html[data-theme="dark"] .v11-element-photo small { color: #526579; }
html[data-theme="dark"] .simulation-frame-wrap { background: #07111d; }
html[data-theme="dark"] .simulation-frame-wrap iframe { background: #fff; }
html[data-theme="dark"] img,
html[data-theme="dark"] canvas,
html[data-theme="dark"] .v13-stage { filter: none; }

/* Alto contraste: mantiene los paneles realmente negros y el texto muy claro. */
html[data-theme="dark"][data-contrast="high"] .button-secondary,
html[data-theme="dark"][data-contrast="high"] .element-display,
html[data-theme="dark"][data-contrast="high"] .table-preview,
html[data-theme="dark"][data-contrast="high"] .table-placeholder,
html[data-theme="dark"][data-contrast="high"] .simulation-viewer,
html[data-theme="dark"][data-contrast="high"] .element-detail,
html[data-theme="dark"][data-contrast="high"] .gallery-card,
html[data-theme="dark"][data-contrast="high"] .periodic-workbench .v12-atom-card,
html[data-theme="dark"][data-contrast="high"] .periodic-workbench .v13-atom-card,
html[data-theme="dark"][data-contrast="high"] .periodic-workbench .v11-element-detail {
  color: #fff;
  border-color: #aab6c5;
  background: #050505;
}
html[data-theme="dark"][data-contrast="high"] .periodic-tile,
html[data-theme="dark"][data-contrast="high"] .periodic-workbench .v11-element-tile {
  color: #fff;
  border-color: #9aa4b2;
  background: #101010;
}

html[data-theme="dark"] .gallery-image-unavailable{background:#1b3045;color:#c4d5e7}html[data-theme="dark"] .gallery-license-details{color:#a9bad0}html[data-theme="dark"] .gallery-license-details summary{color:#9fc6ff}

html[data-theme="dark"] .course-example { background: rgba(189, 135, 72, .12); }
html[data-theme="dark"] .course-answer-option.is-correct { background: rgba(40, 120, 94, .18); }
html[data-theme="dark"] .course-answer-option.is-wrong { background: rgba(182, 91, 83, .16); }
html[data-theme="dark"] .course-quiz-shell { background: var(--color-surface-soft); }
