
/* ============================================================
 BRIEFLY V29.0 — GLOBAL LIGHT-MODE CONTRAST FIX
 Fixes legacy dark surfaces across ALL PHP views.
 ============================================================ */

/* The main bug: old components kept dark backgrounds but inherited
   light-theme text variables. Dark surfaces now explicitly own their
   foreground colors. */
html[data-briefly-theme="light"] :is(
  .v10Stat,.v10DiagnosticLink,.v10TableRow,.v10StatusRow,.v10LogRow,
  .v10SourceRow,.v10AutomationRow,.v10BreakingRow,.v10DynamicsRow,
  .v10Intel,.v10Brief,.v10Why,.v10Compare,.v10LeadLink,
  .v15DeepNews,.v17DeepJump,.v131SourceCard,
  .v25DarkCard,.v25PushCard,.v25SystemCard,
  .v10Card,.v10StoryCard,.v10FeedCard
){
  color:#f4f8fa!important;
}

/* Any ordinary text nested in known dark surfaces must stay readable. */
html[data-briefly-theme="light"] :is(
  .v10Stat,.v10DiagnosticLink,.v10TableRow,.v10StatusRow,.v10LogRow,
  .v10SourceRow,.v10AutomationRow,.v10BreakingRow,.v10DynamicsRow,
  .v25DarkCard,.v25PushCard,.v25SystemCard
) :is(h1,h2,h3,h4,b,strong,label,p){
  color:#f4f8fa!important;
}
html[data-briefly-theme="light"] :is(
  .v10Stat,.v10DiagnosticLink,.v10TableRow,.v10StatusRow,.v10LogRow,
  .v10SourceRow,.v10AutomationRow,.v10BreakingRow,.v10DynamicsRow,
  .v25DarkCard,.v25PushCard,.v25SystemCard
) :is(small,span,em){
  color:#aebfc7!important;
}

/* Diagnostic/system page: these were the unreadable controls in the screenshot. */
html[data-briefly-theme="light"] .v10Stat strong,
html[data-briefly-theme="light"] .v10Stat b{
  color:#f7fbfc!important;
}
html[data-briefly-theme="light"] .v10Stat span,
html[data-briefly-theme="light"] .v10Stat small{
  color:#9fb2bc!important;
}
html[data-briefly-theme="light"] .v10DiagnosticLink,
html[data-briefly-theme="light"] .v10DiagnosticLink :is(b,strong){
  color:#f4f8fa!important;
}
html[data-briefly-theme="light"] .v10DiagnosticLink :is(span,small){
  color:#aebfc7!important;
}
html[data-briefly-theme="light"] .v10DiagnosticLink a,
html[data-briefly-theme="light"] .v10DiagnosticLink > :last-child,
html[data-briefly-theme="light"] .v10TableRow > :last-child,
html[data-briefly-theme="light"] .v10StatusRow > :last-child{
  color:var(--briefly-accent)!important;
}

/* Broad safety net for native buttons/anchors that use the old dark surface. */
html[data-briefly-theme="light"] :is(button,a,[role="button"])[style*="background:#071"],
html[data-briefly-theme="light"] :is(button,a,[role="button"])[style*="background: #071"],
html[data-briefly-theme="light"] :is(button,a,[role="button"])[style*="background:#081"],
html[data-briefly-theme="light"] :is(button,a,[role="button"])[style*="background: #081"],
html[data-briefly-theme="light"] :is(button,a,[role="button"])[style*="background:#091"],
html[data-briefly-theme="light"] :is(button,a,[role="button"])[style*="background: #091"]{
  color:#f4f8fa!important;
}

/* Forms: dark fields get light text; white/light fields get dark text. */
html[data-briefly-theme="light"] :is(input,textarea,select){
  color:#142c37;
}
html[data-briefly-theme="light"] :is(input,textarea,select)[style*="background:#0"],
html[data-briefly-theme="light"] :is(input,textarea,select)[style*="background: #0"]{
  color:#f4f8fa!important;
}
html[data-briefly-theme="light"] :is(input,textarea)::placeholder{color:#788c96!important}
html[data-briefly-theme="light"] :is(input,textarea)[style*="background:#0"]::placeholder,
html[data-briefly-theme="light"] :is(input,textarea)[style*="background: #0"]::placeholder{
  color:#9fb2bc!important;
}

/* Selected settings controls: no more black-on-dark. */
html[data-briefly-theme="light"] :is(
 .v25TopicGrid input:checked+span,
 .v25Segment label input:checked+span,
 .v25Segment button.active,
 .v26TeamCard input:checked+span,
 .v26Appearance button.active
){
  color:#102630!important;
}
html[data-briefly-theme="light"] :is(
 .v25TopicGrid input:checked+span,
 .v25Segment label input:checked+span,
 .v26TeamCard input:checked+span
) :is(b,strong,span,em){
  color:#102630!important;
}

/* But deliberately dark choice tiles always use light foreground. */
html[data-briefly-theme="light"] .is-dark,
html[data-briefly-theme="light"] .is-dark :is(b,strong,span,small,p),
html[data-briefly-theme="light"] [data-dark-surface="1"],
html[data-briefly-theme="light"] [data-dark-surface="1"] :is(b,strong,span,small,p){
  color:#f4f8fa!important;
}

/* Table/system labels and separators */
html[data-briefly-theme="light"] .v10TableRow{
  border-color:rgba(255,255,255,.07)!important;
}
html[data-briefly-theme="light"] .v10TableRow :first-child{
  color:#f4f8fa!important;
}
html[data-briefly-theme="light"] .v10TableRow :last-child{
  color:var(--briefly-accent)!important;
  font-weight:800;
}

/* Keep accent readable on both light and dark surfaces. */
html[data-briefly-theme="light"] :is(.v10DiagnosticLink,.v10TableRow,.v10StatusRow) a{
  color:var(--briefly-accent)!important;
}
