.afs-masthead-rule {
  display: block;
  height: 5px;
  margin-inline: var(--afs-masthead-start, 1.5rem) var(--afs-masthead-end, 1.5rem);
  background: linear-gradient(90deg, #626a4b 0 30%, #a65339 30% 76%, #c49538 76% 100%);
  pointer-events: none;
}

body:has(> #product-dialog.afs-detail-page[open]) > .afs-masthead-rule {
  display: none;
}

/* Keep the existing local links on a compact row beneath the masthead. */
body:has(> .afs-masthead-rule) > [data-afs-page-navigation]:has(> .afs-page-back),
body:has(> .afs-masthead-rule) > .afs-contact-back {
  max-width: none;
  width: auto;
  margin: 0 var(--afs-masthead-end, 1.5rem) 0 var(--afs-masthead-start, 1.5rem) !important;
}

body:has(> .afs-masthead-rule) > [data-afs-page-navigation]:has(> .afs-page-back):not(.afs-sector-navigation),
body:has(> .afs-masthead-rule) > .afs-contact-back {
  padding: 0 !important;
}

body:has(> .afs-masthead-rule) #main > .catalog-navigation-compact:has(> #catalog-back) {
  max-width: none;
  width: auto;
  margin: 0 !important;
  padding-inline: 48px !important;
}

body:has(> .afs-masthead-rule) > .afs-contact-back a,
body:has(> .afs-masthead-rule) > [data-afs-page-navigation] > .afs-page-back {
  box-sizing: border-box;
  display: inline-flex !important;
  align-items: center;
  min-height: 36px;
}

body:has(> .afs-masthead-rule) > .afs-flooring-pilot-nav .afs-flooring-pilot-nav-inner {
  width: auto;
  margin-inline: var(--afs-masthead-start, 1.5rem) var(--afs-masthead-end, 1.5rem);
  gap: 2px 8px;
  padding-block: 2px;
}

body:has(> .afs-masthead-rule) > #room-catalog-return:not([hidden]) {
  padding-inline: var(--afs-masthead-start, 1.5rem) var(--afs-masthead-end, 1.5rem);
  padding-block: 4px;
}

body:has(> .afs-masthead-rule) .edu-main > .edu-hero {
  border-top: 0;
}

body:has(> .afs-masthead-rule[data-afs-layout="products"]) #afs-products-choice {
  border-top: 0;
  padding-block-start: clamp(1.5rem, 3vw, 2.5rem);
}

body:has(> .afs-masthead-rule[data-afs-layout="flooring-resources"]) .flr-hero {
  padding-block-start: clamp(.75rem, 2vw, 1.25rem);
}

body:has(> .afs-masthead-rule[data-afs-layout="services"]) #afs-service-guide .guide-intro {
  padding-block-start: clamp(1.5rem, 4vw, 2.5rem);
}

body:has(> .afs-masthead-rule[data-afs-layout="help"]) .afs-help-page {
  padding-block-start: 1.5rem;
}

body:has(> .afs-masthead-rule[data-afs-layout="flooring"]) .afs-flooring-pilot-nav::before,
body:has(> .afs-masthead-rule[data-afs-layout="hospitality-carpet"]) main > :is(.afs-material-nav, .crumb)::after {
  display: none;
}

/* These existing hero links are the secondary action in their group. */
body:has(> .afs-masthead-rule) a.afs-masthead-secondary {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: .55rem .95rem;
  border: 1px solid #181818 !important;
  border-radius: var(--afs-button-radius, 6px);
  background: #fff !important;
  color: #181818 !important;
  font-weight: 600;
  text-decoration: none;
}

body:has(> .afs-masthead-rule) a.afs-masthead-secondary:hover {
  background: #f5f5f5 !important;
  text-decoration: underline;
}

body:has(> .afs-masthead-rule) :is(a.afs-masthead-secondary, .afs-contact-back a, .afs-page-back):focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

@media (max-width: 760px) {
  body:has(> .afs-masthead-rule) > .afs-contact-back a,
  body:has(> .afs-masthead-rule) > [data-afs-page-navigation] > .afs-page-back {
    min-height: 44px;
  }

  body:has(> .afs-masthead-rule[data-afs-layout="hospitality-carpet"]) main > .afs-material-nav ul {
    display: flex;
    gap: 6px;
    padding: 4px;
    overflow-x: auto;
  }

  body:has(> .afs-masthead-rule[data-afs-layout="hospitality-carpet"]) main > .afs-material-nav li {
    flex: 0 0 auto;
  }

  body:has(> .afs-masthead-rule[data-afs-layout="hospitality-carpet"]) main > .afs-material-nav li a {
    min-height: 44px;
  }
}

@media (max-width: 800px) {
  body:has(> .afs-masthead-rule) #main > .catalog-navigation-compact:has(> #catalog-back) {
    padding-inline: 24px !important;
  }
}

@media (forced-colors: active), print {
  .afs-masthead-rule {
    display: none;
  }
}
