/* Shared, recessed content rules. Keep the existing border widths and layout.
   A dark hairline above a light edge reads as a shallow groove.
   This layer wins over legacy !important surface rules without escalating selectors. */
@layer inset-dividers {
  body.office-catalog-dle {
    --divider-shade: rgba(35, 45, 40, .08);
    --divider-light: rgba(255, 255, 255, .9);
  }

  /* Rules at the beginning of a section or row. */
  main#top > :is(.program-facts, .download-return, .catalog-section),
  main#top:is(.app-detail-page:not(.app-detail-page--apps), :is(.product-page, :has(> #excel-download-start))) > #versions,
  main#top :is(.catalog-facts, .catalog-article-meta),
  main#top:is([data-office-release="/office/2024/"], .app-detail-page:not(.app-detail-page--office, .microsoft-365-page, .app-detail-page--apps), :is(.product-page, :has(> #excel-download-start))) #features .excel-capability,
  .catalog-home-page :is(.ch-choice-action, .ch-faq-list, .ch-source-note, #office-questions),
  .ov-page :is(.ov-sources, .ov-faq, .ov-faq-list details + details) {
    border-top-color: var(--divider-shade) !important;
    box-shadow: inset 0 1px 0 var(--divider-light) !important;
  }

  /* Bottom rules stay inside their row, including on hover and disclosure. */
  main#top :is(.release-head, .release-row, .catalog-fact, .catalog-check-list li, .catalog-hub-hero),
  main#top:is(.app-detail-page:not(.app-detail-page--office, .microsoft-365-page), :is(.product-page, :has(> #excel-download-start))) #faq .faq-topic-panel .faq-item,
  .catalog-home-page :is(.ch-hero, .ch-section-nav, .ch-faq-item),
  .ov-page .ov-intro {
    border-bottom-color: var(--divider-light) !important;
    box-shadow: inset 0 -1px 0 var(--divider-shade) !important;
  }

  /* Section boundaries with a rule on both sides. */
  main#top > .trust-strip,
  main#top:not(:is(.product-page, :has(> #excel-download-start))) > #faq.faq-section,
  .catalog-home-page #office-apps {
    border-top-color: var(--divider-shade) !important;
    border-bottom-color: var(--divider-light) !important;
    box-shadow: inset 0 1px 0 var(--divider-light), inset 0 -1px 0 var(--divider-shade) !important;
  }

  /* The established dark trust strips need a softer light edge. */
  body.office-catalog-dle:not(:has(main#top:is(.product-page, :has(> #excel-download-start)))) .trust-strip {
    --divider-shade: rgba(0, 0, 0, .24);
    --divider-light: rgba(255, 255, 255, .1);
  }

  /* Excel owns its compact comparison layout in excel-light-palette.css. */
  main#top:not(:is(.product-page, :has(> #excel-download-start))) #requirements .requirements-matrix-row + .requirements-matrix-row,
  main#top[data-office-release] #requirements .requirements-matrix-note {
    border-top-color: var(--divider-shade) !important;
    box-shadow: inset 0 1px 0 var(--divider-light) !important;
  }
  main#top:not(:is(.product-page, :has(> #excel-download-start))) #requirements .requirements-matrix-head {
    border-top-color: var(--divider-shade) !important;
    border-bottom-color: var(--divider-light) !important;
    box-shadow: inset 0 1px 0 var(--divider-light), inset 0 -1px 0 var(--divider-shade) !important;
  }

  /* One groove at adjoining section edges, rather than two stacked rules. */
  main#top > .trust-strip + .program-facts,
  main#top > .faq-section + .download-return {
    border-top-color: transparent !important;
    box-shadow: none !important;
  }

  /* The comparison table switches from cell rules to row rules on phones. */
  @media (min-width: 521px) {
    .ov-comparison-table :is(thead tr, tbody tr:not(:last-child)) > :is(th, td) {
      border-bottom-color: var(--divider-light) !important;
      box-shadow: inset 0 -1px 0 var(--divider-shade) !important;
    }
  }
  @media (max-width: 520px) {
    .ov-comparison-table tbody tr:not(:last-child) {
      border-bottom-color: var(--divider-light) !important;
      box-shadow: inset 0 -1px 0 var(--divider-shade) !important;
    }
  }
  @media (max-width: 800px) {
    .ov-version-side {
      border-top-color: var(--divider-shade) !important;
      box-shadow: inset 0 1px 0 var(--divider-light) !important;
    }
  }

  /* Do not introduce new rules at the open ends of the lists. */
  main#top .release-row:last-of-type,
  main#top:is(.product-page, :has(> #excel-download-start)) #features .excel-capability:first-child {
    box-shadow: none !important;
  }
  @media (min-width: 701px) {
    main#top:is(.product-page, :has(> #excel-download-start)) #features .excel-capability:nth-child(2) {
      box-shadow: none !important;
    }
  }
  @media (max-width: 980px) {
    main#top:is(.app-detail-page--apps, .platform-index-page) .release-list {
      border-top-color: var(--divider-shade) !important;
      box-shadow: inset 0 1px 0 var(--divider-light) !important;
    }
  }

  /* Standalone rules and the neutral Excel shell use the same two-tone edge. */
  main#top hr {
    height: 2px;
    border: 0 !important;
    background: linear-gradient(to bottom, var(--divider-shade) 0 1px, var(--divider-light) 1px 2px) !important;
    box-shadow: none !important;
  }
}
