/* Only the historical article masthead adopts the light journal palette.
   The scope ends at nested notices and content sections so their local
   foreground/background pairs and publication records stay intact. */
@media screen {
  @scope (header:has(> h1), section:has(> div > h1), main > div:has(> div > h1))
    to (aside, [role="note"], article, section, table, figure, pre) {
    /* Some archived pages specify their dark gradients and colors inline. */
    :scope {
      background: #f5f5f7 !important;
      color: #1d1d1f;
      border-color: #d2d2d7;
      min-height: 0;
      padding-block: clamp(2.5rem, 5vw, 4.5rem) !important;
      padding-inline: clamp(1rem, 3vw, 2rem);
    }

    :scope::before,
    :scope::after,
    :scope > .absolute.inset-0 {
      display: none;
    }

    h1 {
      font-size: clamp(2rem, 4.4vw, 3.5rem) !important;
      line-height: 1.12 !important;
      letter-spacing: -.035em;
      overflow-wrap: anywhere;
      text-wrap: balance;
    }

    h1:lang(ja), h1:lang(zh) {
      line-height: 1.25 !important;
      letter-spacing: -.015em;
    }

    h1, h1 span {
      background: none !important;
      color: #1d1d1f !important;
      -webkit-text-fill-color: currentColor !important;
      text-shadow: none;
    }

    :is(p, time, small, nav, li, div, span):not(h1 span, a span) {
      color: #424247 !important;
    }

    p strong { color: #1d1d1f !important; }

    a,
    a :is(span, i) {
      color: #005bb5 !important;
    }

    .category-badge, .category-tag, .article-category, .badge, .tag,
    :is(a, span):is([style*="background"], [class*="bg-"]):not(h1 span),
    :is(.language-selector, .lang-switcher) a {
      background: #e8edf4 !important;
      color: #234563 !important;
      border-color: #c6d3e1 !important;
    }

    :is(.language-selector, .lang-switcher) a.active, a[aria-current="page"] {
      background: #d7e8fb !important;
      color: #004a94 !important;
      font-weight: 700;
    }
  }
  /* The in-flow language row already reserves the fixed navigation height. */
  body > vcp-header:has(.language-switcher) + main.pt-20 {
    padding-top: 0;
  }

  body :is(article, .prose) :is(h2, h3) { letter-spacing: -.02em; }
  body :is(article, .prose, .article-content) { overflow-wrap: anywhere; }
  body pre { max-width: 100%; overflow-x: auto; }
  body pre code { overflow-wrap: normal; }
  .journal-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    margin-block: 1.5rem;
  }
  .journal-table-wrap:focus-visible { outline: 2px solid #0071e3; outline-offset: 2px; }
  .journal-table-wrap > table { margin-block: 0; }
  @media (max-width: 600px) {
    body .impact-stats { grid-template-columns: minmax(0, 1fr) !important; }
  }
}
