/* Imported Classic text colours: use reading/state roles without changing the
   stored HTML, media, backgrounds or deliberately white-on-blue table headers. */
.riko-addon[data-catalog-universe="legacy"] .riko-addon__prose :is([style*="color: #002d62" i], [style*="color: #002d61" i], [style*="color: #000000" i], [style*="color: #0066cc" i]):not(a[href]):not(a[href] *) {
  color:var(--riko-reading-ink)!important;
}
.riko-addon[data-catalog-universe="legacy"] .riko-addon__prose :is([style*="color: #ff0000" i], [style*="color: #c00000" i], [style*="color:#c00000" i]):not(a[href]):not(a[href] *) {
  color:var(--riko-danger)!important;
}
/* Authored paper/pastel cells remain light in either UI mode and need dark ink. */
.riko-addon[data-catalog-universe="legacy"] .riko-addon__prose :is(tr, td, th):is([style*="background-color: #f0f0f0" i], [style*="background-color: #f5f5f5" i], [style*="background-color: #fffcc2" i], [style*="background-color: #e0ffe2" i]),
.riko-addon[data-catalog-universe="legacy"] .riko-addon__prose tr[style*="background-color: #f0f0f0" i] > :is(td, th) {
  color:var(--riko-artwork-ink)!important;
}
/* Photo grids may span the reading column; paragraphs, tables and authored
   image sizes retain their existing bounds. Older browsers keep the prose fit. */
@supports (container-type:inline-size) and (width:100cqw) {
  .riko-addon[data-catalog-universe="legacy"] .riko-addon__main {
    container-type:inline-size;
  }
  .riko-addon[data-catalog-universe="legacy"] .riko-addon__main .riko-addon__section .riko-addon__prose [data-rikoooo-editorial-media-v1] > .riko-editorial-grid {
    width:100cqw!important;
    max-width:100cqw!important;
  }
}

/* Imported screenshot grids wrap around each thumbnail's actual width. This
   also covers unclassed JCE images and nested wrappers; tables and standalone
   authored images retain their existing layout and lightbox ownership. */
.riko-addon[data-catalog-universe="legacy"] .riko-addon__prose .riko-editorial-grid:has(a[data-uk-lightbox] > img) {
  display:flex!important;
  flex-wrap:wrap;
  align-items:flex-start;
  gap:8px!important;
}
.riko-addon[data-catalog-universe="legacy"] .riko-addon__prose .riko-editorial-grid:has(a[data-uk-lightbox] > img) .riko-editorial-grid {
  display:contents!important;
}
.riko-addon[data-catalog-universe="legacy"] .riko-addon__prose .riko-editorial-grid a[data-uk-lightbox]:has(> img) {
  display:block!important;
  flex:0 1 auto;
  box-sizing:border-box;
  width:fit-content!important;
  max-width:min(100%, 320px)!important;
  min-width:0;
  margin:0!important;
}
.riko-addon[data-catalog-universe="legacy"] .riko-addon__prose .riko-editorial-grid a[data-uk-lightbox] > img {
  display:block;
  width:auto!important;
  height:auto!important;
  max-width:100%;
  aspect-ratio:auto;
  margin:0!important;
  object-fit:contain;
}
@media (max-width: 640px) {
  .riko-addon[data-catalog-universe="legacy"] .riko-addon__prose .riko-editorial-grid:has(a[data-uk-lightbox] > img) {
    display:grid!important;
    grid-template-columns:repeat(2, minmax(0, 1fr))!important;
    justify-items:start;
  }
}
