/* R715 batch-results contrast and listing-link repair.
   R703 used prefers-color-scheme for runtime-lite surfaces. That rule can win
   while Product Studio is explicitly in Light mode, producing dark cards with
   the old near-black text. Keep this file last so the app-selected theme wins.
   These rules are CSS-only: no observers, timers, or render work are added. */

.r696-compact-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.r696-compact-title-wrap {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.r696-compact-listing-link,
.batch-product-listing-link {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: .78rem;
  line-height: 1.35;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.batch-product-listing {
  display: grid;
  gap: 4px;
  margin-top: 5px;
}

.batch-product-source-note {
  display: block;
  font-size: .78rem;
  line-height: 1.35;
}

/* Default/fallback palette for the brief period before the theme attribute is
   restored. This also keeps the legacy prefers-color-scheme rule readable. */
:is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) {
  color: #1d1725 !important;
  -webkit-text-fill-color: #1d1725 !important;
  background: #ffffff !important;
  border-color: #d8d0e3 !important;
  opacity: 1 !important;
  filter: none !important;
  text-shadow: none !important;
}

:is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) :is(strong, h3, .batch-status-badge, .batch-product-header-actions > span) {
  color: #1d1725 !important;
  -webkit-text-fill-color: #1d1725 !important;
  opacity: 1 !important;
}

:is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) :is(span, small, p, .muted, .batch-product-source-note, .batch-progress-note) {
  color: #665f70 !important;
  -webkit-text-fill-color: #665f70 !important;
  opacity: 1 !important;
}

.r696-compact-heading > span {
  flex: 0 0 auto;
  color: #665f70 !important;
  -webkit-text-fill-color: #665f70 !important;
}

.r696-compact-progress > span {
  background: #6846d8 !important;
}

/* Explicit Light theme: override the OS dark-mode media query in R703. */
html[data-theme="light"] :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card),
body.light :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) {
  color: #1d1725 !important;
  -webkit-text-fill-color: #1d1725 !important;
  background: #ffffff !important;
  border-color: #d8d0e3 !important;
}

html[data-theme="light"] :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) :is(strong, h3, .batch-status-badge, .batch-product-header-actions > span),
body.light :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) :is(strong, h3, .batch-status-badge, .batch-product-header-actions > span) {
  color: #1d1725 !important;
  -webkit-text-fill-color: #1d1725 !important;
}

html[data-theme="light"] :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) :is(span, small, p, .muted, .batch-product-source-note, .batch-progress-note),
body.light :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) :is(span, small, p, .muted, .batch-product-source-note, .batch-progress-note) {
  color: #665f70 !important;
  -webkit-text-fill-color: #665f70 !important;
}

html[data-theme="light"] :is(.r696-compact-listing-link, .batch-product-listing-link),
body.light :is(.r696-compact-listing-link, .batch-product-listing-link) {
  color: #5131a5 !important;
  -webkit-text-fill-color: #5131a5 !important;
}

html[data-theme="light"] .r696-compact-progress > span,
body.light .r696-compact-progress > span {
  background: #6846d8 !important;
}

/* Explicit Night theme remains dark, but every runtime string is readable. */
html[data-theme="dark"] :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card),
body.dark :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) {
  color: #f4f1f8 !important;
  -webkit-text-fill-color: #f4f1f8 !important;
  background: #171920 !important;
  border-color: #484552 !important;
}

html[data-theme="dark"] :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) :is(strong, h3, .batch-status-badge, .batch-product-header-actions > span),
body.dark :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) :is(strong, h3, .batch-status-badge, .batch-product-header-actions > span) {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

html[data-theme="dark"] :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) :is(span, small, p, .muted, .batch-product-source-note, .batch-progress-note),
body.dark :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) :is(span, small, p, .muted, .batch-product-source-note, .batch-progress-note) {
  color: #c9c3d1 !important;
  -webkit-text-fill-color: #c9c3d1 !important;
}

html[data-theme="dark"] :is(.r696-compact-listing-link, .batch-product-listing-link),
body.dark :is(.r696-compact-listing-link, .batch-product-listing-link) {
  color: #c7b2ff !important;
  -webkit-text-fill-color: #c7b2ff !important;
}

html[data-theme="dark"] .r696-compact-progress > span,
body.dark .r696-compact-progress > span {
  background: #b49aff !important;
}

@media (prefers-color-scheme: dark) {
  /* Only the fallback state uses the OS palette. An explicit app theme above
     wins through the later selectors. */
  html:not([data-theme]) body:not(.light):not(.dark) :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) {
    color: #f4f1f8 !important;
    -webkit-text-fill-color: #f4f1f8 !important;
    background: #171920 !important;
    border-color: #484552 !important;
  }
  html:not([data-theme]) body:not(.light):not(.dark) :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) :is(strong, h3, .batch-status-badge, .batch-product-header-actions > span) {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
  }
  html:not([data-theme]) body:not(.light):not(.dark) :is(#r696RuntimeBanner, .r696-approval-suspended, .r696-compact-batch-card, .batch-product-card) :is(span, small, p, .muted, .batch-product-source-note, .batch-progress-note) {
    color: #c9c3d1 !important;
    -webkit-text-fill-color: #c9c3d1 !important;
  }
  html:not([data-theme]) body:not(.light):not(.dark) :is(.r696-compact-listing-link, .batch-product-listing-link) {
    color: #c7b2ff !important;
    -webkit-text-fill-color: #c7b2ff !important;
  }
}

/* R718: fixed four-plus-four previews and session-wide generation view. */
.batch-fixed-image-preview,
.current-session-generations-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
}
.batch-fixed-preview-heading,
.current-session-generations-heading,
.current-session-product-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.batch-fixed-preview-heading span,
.batch-fixed-preview-group h4 small,
.current-session-generations-heading .help,
.current-session-product-heading a {
  color: var(--muted);
}
.batch-fixed-preview-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.batch-fixed-preview-group { min-width: 0; }
.batch-fixed-preview-group h4 { margin: 0 0 8px; color: var(--ink); }
.batch-fixed-preview-group h4 small { font-size: .78em; font-weight: 700; }
.batch-fixed-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.batch-fixed-preview-slot {
  position: relative;
  display: grid;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  place-items: end start;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--soft);
  color: var(--ink);
  text-decoration: none;
}
.batch-fixed-preview-slot img { width: 100%; height: 100%; object-fit: cover; grid-area: 1 / 1; }
.batch-fixed-preview-slot > span,
.batch-fixed-preview-placeholder > strong,
.batch-fixed-preview-placeholder > small {
  position: relative;
  z-index: 1;
  margin: 0 5px 5px;
  padding: 3px 5px;
  border-radius: 6px;
  background: rgba(17, 24, 39, .78);
  color: #fff;
  font-size: 10px;
  line-height: 1.15;
}
.batch-fixed-preview-placeholder { place-items: center; align-content: center; text-align: center; padding: 5px; }
.batch-fixed-preview-placeholder > strong,
.batch-fixed-preview-placeholder > small { margin: 0; background: transparent; color: var(--muted); }
.batch-fixed-preview-placeholder > small { display: block; font-size: 10px; }
.current-session-generations-panel[hidden] { display: none !important; }
.current-session-generations-heading h3 { margin: 3px 0 5px; }
.current-session-generations-heading .help { margin: 0; max-width: 760px; }
.current-session-generations-heading-actions,
.current-session-product-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.current-session-generations-list { display: grid; gap: 14px; margin-top: 14px; }
.current-session-product { padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--soft); }
.current-session-product-heading h3 { margin: 2px 0 4px; }
.current-session-product-heading a { display: block; max-width: 700px; overflow-wrap: anywhere; font-size: 12px; }
.current-session-preview { margin-top: 12px; background: var(--card); }
body.r696-runtime-lite .batch-fixed-image-preview img,
body.r696-runtime-lite .current-session-generations-panel img,
html.r696-runtime-lite .batch-fixed-image-preview img,
html.r696-runtime-lite .current-session-generations-panel img { visibility: visible !important; }
@media (max-width: 760px) {
  .batch-fixed-preview-groups { grid-template-columns: 1fr; }
  .batch-fixed-preview-grid { gap: 6px; }
  .current-session-product-actions { width: 100%; }
}
