/* R711: complete Light/Night contrast recovery.
   The app mixes an editorial dark theme with several intentionally light utility
   panels. Older global selectors forced white labels into those light panels and
   forced white manual-save text into the light header. This final stylesheet is
   loaded last and pairs every affected surface with an explicit readable text
   palette. It contains no observers, timers, animations, or layout rebuilding. */

/* ---------- Header: manual-save status must be visible in both themes ---------- */
html[data-theme="light"] body.r120-rice-ui .app-header .header-actions #autosaveStatus {
  color: #4e4758 !important;
  -webkit-text-fill-color: #4e4758 !important;
  background: rgba(255,255,255,.92) !important;
  border: 1px solid rgba(76,65,96,.18) !important;
  opacity: 1 !important;
}
html[data-theme="light"] body.r120-rice-ui .app-header .header-actions #autosaveStatus.warn {
  color: #744800 !important;
  -webkit-text-fill-color: #744800 !important;
  background: #fff6d9 !important;
  border-color: #dfb85a !important;
}
html[data-theme="light"] body.r120-rice-ui .app-header .header-actions #autosaveStatus.saved {
  color: #096b48 !important;
  -webkit-text-fill-color: #096b48 !important;
  background: #eefaf5 !important;
  border-color: #83cfb0 !important;
}
html[data-theme="light"] body.r120-rice-ui .app-header .header-actions #autosaveStatus.saving {
  color: #5730ad !important;
  -webkit-text-fill-color: #5730ad !important;
  background: #f4efff !important;
  border-color: #b8a2e8 !important;
}
html[data-theme="light"] body.r120-rice-ui .app-header .header-actions #autosaveStatus.error {
  color: #9a2018 !important;
  -webkit-text-fill-color: #9a2018 !important;
  background: #fff0ef !important;
  border-color: #e2a29d !important;
}
html[data-theme="dark"] body.r120-rice-ui .app-header .header-actions #autosaveStatus {
  color: #ddd8e6 !important;
  -webkit-text-fill-color: #ddd8e6 !important;
  background: #211e2a !important;
  border: 1px solid #494256 !important;
  opacity: 1 !important;
}
html[data-theme="dark"] body.r120-rice-ui .app-header .header-actions #autosaveStatus.warn {
  color: #ffd987 !important;
  -webkit-text-fill-color: #ffd987 !important;
  background: #352a14 !important;
  border-color: #806532 !important;
}
html[data-theme="dark"] body.r120-rice-ui .app-header .header-actions #autosaveStatus.saved {
  color: #7be0b2 !important;
  -webkit-text-fill-color: #7be0b2 !important;
  background: #143027 !important;
  border-color: #2b7259 !important;
}
html[data-theme="dark"] body.r120-rice-ui .app-header .header-actions #autosaveStatus.saving {
  color: #cdbdff !important;
  -webkit-text-fill-color: #cdbdff !important;
  background: #28213d !important;
  border-color: #655298 !important;
}
html[data-theme="dark"] body.r120-rice-ui .app-header .header-actions #autosaveStatus.error {
  color: #ffaaa3 !important;
  -webkit-text-fill-color: #ffaaa3 !important;
  background: #3b1d1c !important;
  border-color: #87423e !important;
}

/* Light header/system copy was previously inheriting the dark editorial white. */
html[data-theme="light"] body.r120-rice-ui .app-header .topbar-health,
html[data-theme="light"] body.r120-rice-ui .app-header .topbar-health span,
html[data-theme="light"] body.r120-rice-ui .app-header .topbar-health small {
  color: #5f5869 !important;
  -webkit-text-fill-color: #5f5869 !important;
}
html[data-theme="light"] body.r120-rice-ui .app-header .topbar-health strong {
  color: #17131f !important;
  -webkit-text-fill-color: #17131f !important;
}

/* ---------- Night mode: light utility surfaces need dark text ---------- */
html[data-theme="dark"] body.r120-rice-ui :is(
  .catalog-database-browser,
  .catalog-product-metric-filters,
  .catalog-finder-metric-filters,
  .catalog-search-selection-toolbar,
  .catalog-database-selection-toolbar,
  .catalog-finder-exclusion-tools .catalog-exclude-history,
  .catalog-keyword-match-row,
  .catalog-search-empty,
  .catalog-search-result,
  .catalog-database-row,
  .catalog-source-row,
  .catalog-source-manager,
  .digital-relationship-panel,
  .digital-prompt-family-selector,
  .digital-version-slider,
  .digital-preserve-seo-option,
  .image-quality-choice-button
) {
  color: #18131f !important;
  -webkit-text-fill-color: #18131f !important;
}

html[data-theme="dark"] body.r120-rice-ui :is(
  .catalog-database-browser,
  .catalog-product-metric-filters,
  .catalog-finder-metric-filters,
  .catalog-search-selection-toolbar,
  .catalog-database-selection-toolbar,
  .catalog-finder-exclusion-tools .catalog-exclude-history,
  .catalog-keyword-match-row,
  .catalog-search-empty,
  .catalog-search-result,
  .catalog-database-row,
  .catalog-source-row,
  .catalog-source-manager,
  .digital-relationship-panel,
  .digital-prompt-family-selector,
  .digital-version-slider,
  .digital-preserve-seo-option,
  .image-quality-choice-button
) :is(h1,h2,h3,h4,h5,h6,strong,b,label,legend,summary) {
  color: #18131f !important;
  -webkit-text-fill-color: #18131f !important;
  opacity: 1 !important;
}

html[data-theme="dark"] body.r120-rice-ui :is(
  .catalog-database-browser,
  .catalog-product-metric-filters,
  .catalog-finder-metric-filters,
  .catalog-search-selection-toolbar,
  .catalog-database-selection-toolbar,
  .catalog-finder-exclusion-tools .catalog-exclude-history,
  .catalog-keyword-match-row,
  .catalog-search-empty,
  .catalog-search-result,
  .catalog-database-row,
  .catalog-source-row,
  .catalog-source-manager,
  .digital-relationship-panel,
  .digital-prompt-family-selector,
  .digital-version-slider,
  .digital-preserve-seo-option,
  .image-quality-choice-button
) :is(p,small,.help,.muted,.catalog-metric-filter-note,.catalog-finder-metric-filter-note,.catalog-database-view-summary,.catalog-database-row-main small,.catalog-search-result-copy small) {
  color: #625b6c !important;
  -webkit-text-fill-color: #625b6c !important;
  opacity: 1 !important;
}

/* Inputs that live on light cards must not keep the dark global input palette. */
html[data-theme="dark"] body.r120-rice-ui :is(
  .catalog-database-browser,
  .catalog-product-metric-filters,
  .catalog-finder-metric-filters,
  .catalog-search-selection-toolbar,
  .catalog-database-selection-toolbar,
  .digital-relationship-panel,
  .digital-prompt-family-selector,
  .digital-version-slider,
  .image-quality-choice-button
) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),select,textarea) {
  color: #18131f !important;
  -webkit-text-fill-color: #18131f !important;
  background: #ffffff !important;
  border-color: #d7d1df !important;
  opacity: 1 !important;
}
html[data-theme="dark"] body.r120-rice-ui :is(
  .catalog-database-browser,
  .catalog-product-metric-filters,
  .catalog-finder-metric-filters,
  .digital-relationship-panel,
  .digital-prompt-family-selector,
  .digital-version-slider
) :is(input,textarea)::placeholder {
  color: #777080 !important;
  -webkit-text-fill-color: #777080 !important;
  opacity: 1 !important;
}

/* Preserve intentional dark chips/rows that sit inside otherwise light panels. */
html[data-theme="dark"] body.r120-rice-ui :is(
  .catalog-search-result-rank,
  .catalog-source-type,
  .catalog-removed-rows-disclosure > summary
),
html[data-theme="dark"] body.r120-rice-ui :is(
  .catalog-search-result-rank,
  .catalog-source-type,
  .catalog-removed-rows-disclosure > summary
) * {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

/* The quality cards remain white/light; assign their own complete palette. */
html[data-theme="dark"] body.r120-rice-ui .image-quality-choice-button,
html[data-theme="dark"] body.r120-rice-ui .image-quality-choice-button strong {
  color: #18131f !important;
  -webkit-text-fill-color: #18131f !important;
}
html[data-theme="dark"] body.r120-rice-ui .image-quality-choice-button small {
  color: #625b6c !important;
  -webkit-text-fill-color: #625b6c !important;
}
html[data-theme="dark"] body.r120-rice-ui .image-quality-choice-button .image-quality-choice-icon,
html[data-theme="dark"] body.r120-rice-ui .image-quality-choice-button .image-quality-choice-check {
  color: #5c35bd !important;
  -webkit-text-fill-color: #5c35bd !important;
}
html[data-theme="dark"] body.r120-rice-ui .image-quality-choice-button.active .image-quality-choice-icon,
html[data-theme="dark"] body.r120-rice-ui .image-quality-choice-button[aria-pressed="true"] .image-quality-choice-icon,
html[data-theme="dark"] body.r120-rice-ui .image-quality-choice-button.active .image-quality-choice-check,
html[data-theme="dark"] body.r120-rice-ui .image-quality-choice-button[aria-pressed="true"] .image-quality-choice-check {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

/* API/automation cards are truly dark in Night mode; repair older light-text tokens. */
html[data-theme="dark"] body.r120-rice-ui :is(.optional-api-panel,.api-setup-card,.automation-ai-grid,.automation-model-selector-field) {
  color: #f4f2f8 !important;
  -webkit-text-fill-color: #f4f2f8 !important;
}
html[data-theme="dark"] body.r120-rice-ui :is(.optional-api-panel,.api-setup-card,.automation-ai-grid,.automation-model-selector-field) :is(h1,h2,h3,h4,strong,b,label,summary) {
  color: #f4f2f8 !important;
  -webkit-text-fill-color: #f4f2f8 !important;
}
html[data-theme="dark"] body.r120-rice-ui :is(.optional-api-panel,.api-setup-card,.automation-ai-grid,.automation-model-selector-field) :is(p,li,small,.help,.muted) {
  color: #c3bdcd !important;
  -webkit-text-fill-color: #c3bdcd !important;
}

/* ---------- Light mode: remove remaining white-on-white inheritance ---------- */
html[data-theme="light"] body.r120-rice-ui :is(.eyebrow,.section-kicker) {
  color: #a43c0c !important;
  -webkit-text-fill-color: #a43c0c !important;
}
html[data-theme="light"] body.r120-rice-ui .workflow-page-kicker {
  color: #087659 !important;
  -webkit-text-fill-color: #087659 !important;
}
html[data-theme="light"] body.r120-rice-ui :is(.csv-drop-number,.catalog-database-import-icon,.step-number) {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  background: #694bf1 !important;
}
html[data-theme="light"] body.r120-rice-ui .r120-pipeline-list :is(em.ready,em.synced) {
  color: #08734d !important;
  -webkit-text-fill-color: #08734d !important;
}
html[data-theme="light"] body.r120-rice-ui .r120-pipeline-list em.stable {
  color: #086a96 !important;
  -webkit-text-fill-color: #086a96 !important;
}
html[data-theme="light"] body.r120-rice-ui .r120-pipeline-list em.build {
  color: #825400 !important;
  -webkit-text-fill-color: #825400 !important;
}
html[data-theme="light"] body.r120-rice-ui .r120-kpi-card p b,
html[data-theme="light"] body.r120-rice-ui .r120-chart-footer b {
  color: #08734d !important;
  -webkit-text-fill-color: #08734d !important;
}

/* ---------- Dark mode: small accent text must remain bright enough ---------- */
html[data-theme="dark"] body.r120-rice-ui .section-kicker {
  color: #bda7ff !important;
  -webkit-text-fill-color: #bda7ff !important;
}
html[data-theme="dark"] body.r120-rice-ui .workflow-page-badge {
  color: #c9b8ff !important;
  -webkit-text-fill-color: #c9b8ff !important;
}

/* Never use disabled opacity on an entire text-rich panel. */
html[data-theme="light"] body.r120-rice-ui :is(.catalog-product-metric-filters,.catalog-finder-metric-filters),
html[data-theme="dark"] body.r120-rice-ui :is(.catalog-product-metric-filters,.catalog-finder-metric-filters) {
  opacity: 1 !important;
  filter: none !important;
}

/* Exact fallbacks for older WebKit text-fill declarations. */
html[data-theme="light"] body.r120-rice-ui .r120-pipeline-list em.ready,
html[data-theme="light"] body.r120-rice-ui .r120-pipeline-list em.synced {
  color: #08734d !important;
  -webkit-text-fill-color: #08734d !important;
}
html[data-theme="light"] body.r120-rice-ui .r120-pipeline-list em.stable {
  color: #086a96 !important;
  -webkit-text-fill-color: #086a96 !important;
}
html[data-theme="light"] body.r120-rice-ui .r120-pipeline-list em.build {
  color: #825400 !important;
  -webkit-text-fill-color: #825400 !important;
}
html[data-theme="dark"] body.r120-rice-ui #catalogRemovedRowsSummary {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}
html[data-theme="dark"] body.r120-rice-ui .catalog-filter-removal-summary strong {
  color: #4b278f !important;
  -webkit-text-fill-color: #4b278f !important;
}
html[data-theme="dark"] body.r120-rice-ui .catalog-filter-removal-summary span {
  color: #57505f !important;
  -webkit-text-fill-color: #57505f !important;
}
html[data-theme="light"] body.r120-rice-ui .workflow-page-badge {
  color: #087457 !important;
  -webkit-text-fill-color: #087457 !important;
}
